pyrit.prompt_converter.AddTextImageConverter#

class AddTextImageConverter(text_to_add: str, font_name: str | None = 'arial.ttf', color: tuple[int, int, int] | None = (0, 0, 0), font_size: int | None = 15, x_pos: int | None = 10, y_pos: int | None = 10)[source]#

Bases: PromptConverter

Adds a string to an image and wraps the text into multiple lines if necessary.

Parameters:
  • text_to_add (str) – Text to add to an image. Defaults to empty string.

  • font_name (str, Optional) – Path of font to use. Must be a TrueType font (.ttf). Defaults to “arial.ttf”.

  • color (tuple, Optional) – Color to print text in, using RGB values. Defaults to (0, 0, 0).

  • font_size (float, Optional) – Size of font to use. Defaults to 15.

  • x_pos (int, Optional) – X coordinate to place text in (0 is left most). Defaults to 10.

  • y_pos (int, Optional) – Y coordinate to place text in (0 is upper most). Defaults to 10.

__init__(text_to_add: str, font_name: str | None = 'arial.ttf', color: tuple[int, int, int] | None = (0, 0, 0), font_size: int | None = 15, x_pos: int | None = 10, y_pos: int | None = 10)[source]#

Methods

__init__(text_to_add[, font_name, color, ...])

convert_async(*, prompt[, input_type])

Converter that adds text to an image

convert_tokens_async(*, prompt[, ...])

Converts substrings within a prompt that are enclosed by specified start and end tokens.

get_identifier()

input_supported(input_type)

Checks if the input type is supported by the converter

async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error'] = 'image_path') ConverterResult[source]#

Converter that adds text to an image

Parameters:
  • prompt (str) – The filename of the image to add the text to

  • input_type (PromptDataType) – type of data

Returns:

The filename of the converted image as a ConverterResult Object

Return type:

ConverterResult

input_supported(input_type: Literal['text', 'image_path', 'audio_path', 'url', 'error']) bool[source]#

Checks if the input type is supported by the converter

Parameters:

input_type – The input type to check

Returns:

True if the input type is supported, False otherwise

Return type:

bool