QR Code image generator with customizable image formats, error correction levels, and styling options
Build a command-line tool that generates QR codes with different mask patterns and analyzes their visual characteristics to help determine the optimal pattern for specific use cases.
QR codes use mask patterns to distribute dark and light modules more evenly across the code, improving scannability. Different mask patterns can produce visually distinct QR codes from the same data. Your tool should generate QR codes using all available mask patterns and provide visual comparison.
Create a Python program that accepts data as input and generates multiple QR code images, one for each available mask pattern (patterns 0-7). Each generated image should be clearly labeled with its corresponding mask pattern number.
The program should:
qr_mask_0.png, qr_mask_1.png, etc.)For each mask pattern from 0 to 7:
When given the text "HELLO WORLD", the program generates 8 PNG files named qr_mask_0.png through qr_mask_7.png, each containing a valid QR code with the corresponding mask pattern applied @test
When given the text "https://example.com", all 8 generated QR codes decode to the same original URL when scanned, despite having different visual patterns @test
The generated files are saved in a clean output directory structure @test
@generates
def generate_qr_with_mask(data: str, mask_pattern: int, output_path: str) -> None:
"""
Generate a QR code image with a specific mask pattern.
Args:
data: The text data to encode in the QR code
mask_pattern: The mask pattern number (0-7) to apply
output_path: The file path where the PNG image should be saved
"""
pass
def generate_all_masks(data: str, output_dir: str = ".") -> list[str]:
"""
Generate QR codes for all 8 mask patterns.
Args:
data: The text data to encode in the QR code
output_dir: Directory where output files should be saved (default: current directory)
Returns:
List of generated file paths
"""
pass
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print("Usage: python mask_comparator.py <text_data>")
sys.exit(1)
data = sys.argv[1]
generate_all_masks(data)Python QR code generation library with support for mask pattern selection.
@satisfied-by
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10