QR Code image generator with customizable image formats, error correction levels, and styling options
Build a QR code generation utility that creates customized QR codes with specific configuration requirements.
You need to implement a QR code generator function that accepts configuration parameters and generates a QR code with the specified settings.
Create a function generate_configured_qr(data, config) that:
data containing the information to encodeconfig with the following optional keys:
version: QR code version (integer 1-40, or None for auto-fit)error_correction: Error correction level (string: 'L', 'M', 'Q', or 'H')box_size: Size of each box in pixels (integer, default 10)border: Border width in boxes (integer, default 4)version is None or not provided, the QR code should auto-fit to the databox_size must be at least 1 pixelborder must be at least 4 boxes (QR code specification minimum)@generates
def generate_configured_qr(data: str, config: dict):
"""
Generate a QR code with custom configuration.
Args:
data: String data to encode in the QR code
config: Dictionary with optional keys:
- version (int or None): QR version 1-40, None for auto-fit
- error_correction (str): 'L', 'M', 'Q', or 'H'
- box_size (int): Size of each box in pixels
- border (int): Border width in boxes
Returns:
PIL Image object containing the QR code
"""
passProvides QR code generation and configuration capabilities.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10