pyrit.prompt_converter.QRCodeConverter#

class QRCodeConverter(scale: int = 3, border: int = 4, dark_color: tuple = (0, 0, 0), light_color: tuple = (255, 255, 255), data_dark_color: tuple | None = None, data_light_color: tuple | None = None, finder_dark_color: tuple | None = None, finder_light_color: tuple | None = None, border_color: tuple | None = None)[source]#

Bases: PromptConverter

Converts a text string to a QR code image.

Parameters:
  • scale (int, Optional) – Scaling factor that determines the width/height in pixels of each black/white square (known as a “module”) in the QR code. Defaults to 3.

  • border (int, Optional) – Controls how many modules thick the border should be. Defaults to recommended value of 4.

  • dark_color (tuple, Optional) – Sets color of dark modules, using RGB values. Defaults to black: (0, 0, 0).

  • light_color (tuple, Optional) – Sets color of light modules, using RGB values. Defaults to white: (255, 255, 255).

  • data_dark_color (tuple, Optional) – Sets color of dark data modules (the modules that actually stores the data), using RGB values. Defaults to dark_color.

  • data_light_color (tuple, Optional) – Sets color of light data modules, using RGB values. Defaults to light_color.

  • finder_dark_color (tuple, Optional) – Sets dark module color of finder patterns (squares located in three corners), using RGB values. Defaults to dark_color.

  • finder_light_color (tuple, Optional) – Sets light module color of finder patterns, using RGB values. Defaults to light_color.

  • border_color (tuple, Optional) – Sets color of border, using RGB values. Defaults to light_color.

__init__(scale: int = 3, border: int = 4, dark_color: tuple = (0, 0, 0), light_color: tuple = (255, 255, 255), data_dark_color: tuple | None = None, data_light_color: tuple | None = None, finder_dark_color: tuple | None = None, finder_light_color: tuple | None = None, border_color: tuple | None = None)[source]#

Methods

__init__([scale, border, dark_color, ...])

convert_async(*, prompt[, input_type])

Converter that converts string to QR code 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'] = 'text') ConverterResult[source]#

Converter that converts string to QR code image.

Parameters:
  • prompt (str) – The prompt to be converted.

  • input_type (PromptDataType) – Type of data to be converted. Defaults to “text”.

Returns:

The filename of the converted QR code 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