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
output_supported
(output_type)Checks if the output type is supported by the converter
Attributes
supported_input_types
Returns a list of supported input types for the converter.
supported_output_types
Returns a list of supported output types for the converter.
- async convert_async(*, prompt: str, input_type: Literal['text', 'image_path', 'audio_path', 'video_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:
- input_supported(input_type: Literal['text', 'image_path', 'audio_path', 'video_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:
- output_supported(output_type: Literal['text', 'image_path', 'audio_path', 'video_path', 'url', 'error']) bool [source]#
Checks if the output type is supported by the converter
- Parameters:
output_type – The output type to check
- Returns:
True if the output type is supported, False otherwise
- Return type: