toolbox module¶
Supplemental script which handles Gimp’s creative tools.
This code uses gimpfu. Written for Gimp 2.10.18 which uses Python 2.7.18.
-
class
toolbox.
Toolbox
(data_folder, xml_file)[source]¶ Blueprint-to-image manipulation tool.
This class offers means for creating common card components (i.e. text, icons). Then completes the image and optionally saves it. Probably you’ll want to fine-tune the image manually.
- Parameters
-
create_image
(card_ID)[source]¶ Blueprint to image.
Layout consists of layers which are called alphabetically.
- Parameters
card_ID (str) – Path to the starting node.
- Raises
RuntimeError – If there is no blueprint
KeyError – If any of the layers has no type
ValueError – If any of the layers has unknown type
-
_layer_image
(size, name='Card Assembler Image', **kwargs)[source]¶ Create new image. Needed for layer creation.
- Parameters
size (tuple) – Image dimensions in pixels
name (str) – Image name, defaults to “Card Assembler Image”
-
_layer_monochrome
(size, color, name='Monochrome', position=(0, 0), add_to_position=0, **kwargs)[source]¶ Single color filled layer.
- Parameters
size (tuple) – Layer dimensions in pixels
color (str) – Layer color in hex code
name (str, optional) – Layer name, defaults to “Monochrome”
position (tuple, optional) – Defaults to (0, 0)
add_to_position (int, optional) – Position among layers (-1 adds the layer to a recently defined group), defaults to 0
- Raises
RuntimeError – If there is no image
-
_layer_import_layer_load
(filename, name, **kwargs)[source]¶ Load new data image.
The file has to be in the data folder. Filename is specified in the XML file. Name parameter is used in the XML file to reference the imported file. That’s why it’s not an optional parameter.
-
_layer_import_layer
(target_file, target_layer, add_to_position=0, name=None, position=(0, 0), **kwargs)[source]¶ Copy layer from a data image.
- Parameters
target_file (str) – Use name filled in
import_layer_load
target_layer (str) – Name of the layer to be imported in the target file
add_to_position (int, optional) – Position among layers (-1 adds the layer to a recently defined group), defaults to 0
name (str or None, optional) – Layer name, defaults to target_layer
position (tuple, optional) – Defaults to (0, 0)
- Raises
RuntimeError – If there is no image
-
_layer_group
(add_to_position=0, name='Group', **kwargs)[source]¶ Create new layer group.
To fill next layers in, set theirs add_to_position parameter to
-1
.
-
_layer_text
(text, font, font_size, font_scale=1, add_to_position=0, name=None, color='#000000', size=None, line_spacing=0, letter_spacing=0, justification=0, position=(0, 0), **kwargs)[source]¶ Text layer.
- Parameters
text (str) – Text
font (str) – Font name
font_size (int) – Font size
font_scale (float, optional) – Multiply font_size, defaults to 1
add_to_position (int, optional) – Position among layers (-1 adds the layer to a recently defined group), defaults to 0
name (str or None, optional) – Layer name, defaults to None (Gimp default)
color (str, optional) – Text color in hex code, defaults to “#000000”
size (tuple or None) – Layer dimensions in pixels, defaults to None (autosize)
line_spacing (float, optional) – Line separation change, defaults to 0
letter_spacing (float, optional) – Letters separation change, defaults to 0
justification (int, optional) – Either left(0), right(1), center(2) or fill(3), defaults to 0
position (tuple, optional) – Defaults to (0, 0)
- Raises
RuntimeError – If there is no image
-
_layer_select
(mode='select', left=0, right=100, top=0, bottom=100, **kwargs)[source]¶ New selection by percentage of image size.
- Parameters
mode (str) – Either “select”, “select_invert” or “deselect”, defaults to “select”
left (float, optional) – Left edge position in percentage of the image size, defaults to 0
right (float, optional) – Right edge position in percentage of the image size, defaults to 100
top (float, optional) – Top edge position in percentage of the image size, defaults to 0
botton – Bottom edge position in percentage of the image size, defaults to 100
- Raises
RuntimeError – If there is no image
ArithmeticError – If width is not positive
ArithmeticError – If height is not positive
ValueError – If mode is unknown
-
_layer_mask
(target_layer, **kwargs)[source]¶ Mask layer.
Create a mask for the given layer from the given selection.
- Parameters
target_layer (str) – Layer to be masked
kwargs (various, optional) – Additional named arguments are passed to
select
-
_layer_hide
(**kwargs)[source]¶ Ignore command.
Used for overrides, i.e. hiding a predefined (template) layer.