image_processor module

class image_processor.ImageProcessor(app, canvas_gm, overlay_gm)[source]

Bases: object

Handles the Image rendering and save operations.

generate_sequence_code_image(sequence_code)[source]

Generates an image from the sequence code.

Returns:

An RGB Image with the sequence code

get_highlight_color()[source]

Adds 50% transparency to the current fill_color to emulate highlight color :returns: Hex color :rtype: str

get_resized_coordinates(item=None)[source]

Scales the coordinates to match the size of the transparent film layer in which the images are being drawn on.

Parameters:

item (str,optional) – “text” in the item is text.

Returns:

Scaled coordinates matching the enlarged film layer size.

Return type:

(list|tuple)

get_values_for_overlay_layer_from_overlaycache(coordinates=None, item=None)[source]

Resize element values to whatever size the current overlay film layer is at.(including scaled up for antialiasing)

Parameters:
  • coordinates (list|tuple) – Coordinates to be scaled to match the current overlay size.

  • item (str,optional) – “font”, “image”, “text”, “width”

Returns:

Scaled coordinates matching the current overlay film size.

insert_overlay_image_element()[source]

Renders the overlay image element to the overlay cel layer.

Returns:

None

insert_text(canvas)[source]

Renders graphic elements plotted using the Text tool onto the given canvas draw object.

Parameters:

canvas – PIL draw object.

Returns:

None

plot_brush_stroke(canvas)[source]

Renders graphic elements plotted using the Brush tool onto the given canvas draw object.

Parameters:

canvas – PIL draw object.

Returns:

None

plot_graphic_element(layer: str)[source]

Adjusts the values and calls the specified method to plot the graphic element to an image.

Parameters:

layer (str) – If the overlay elements are being drawn then,”overlay”. Else “base”

Returns:

None

plot_line(canvas)[source]

Renders graphic elements plotted using the Line tool onto the given canvas draw object.

Parameters:

canvas – PIL draw object.

Returns:

None

plot_oval(canvas)[source]

Renders graphic elements plotted using the Oval tool onto the given canvas draw object.

Parameters:

canvas – PIL draw object.

Returns:

None

plot_rectangle(canvas)[source]

Renders graphic elements plotted using the Rectangle tool onto the given canvas draw object.

Parameters:

canvas – PIL draw object.

Returns:

None

prepare_overlay_layer()[source]

Prepares a transparent image in the 16:9 ratio for the graphic elements to be drawn onto. :returns: None

render_images(batch: bool)[source]

Renders the graphic annotations onto the images and saves the images in the specified folder.

Parameters:

batch (bool) – True renders every image in queue, False renders the current image on display.

Returns:

True on successful render of all images. Else False.

Return type:

bool

round_cap(fill_color, canvas)[source]

Uses the start and end coordinate of a segment to draw two circles to generate round tips.

Parameters:
  • fill_color – Hex color code.

  • canvas – PIL draw object.

Returns:

None