From b926f0e6f77731f2271bd3091612f52b403d4e7e Mon Sep 17 00:00:00 2001 From: Mikkeli Matlock Date: Wed, 26 Aug 2026 14:58:28 +0900 Subject: [PATCH] migrating legacy contents --- ,gitignore | 3 +++ qr.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 ,gitignore create mode 100644 qr.py diff --git a/,gitignore b/,gitignore new file mode 100644 index 0000000..2dba6e8 --- /dev/null +++ b/,gitignore @@ -0,0 +1,3 @@ +# artifacts +output/ +*.svg diff --git a/qr.py b/qr.py new file mode 100644 index 0000000..601c049 --- /dev/null +++ b/qr.py @@ -0,0 +1,41 @@ +import qrcode +import argparse +import os + +def main(input_text, output_filename): + # Add .png extension if not present + if not output_filename.endswith(".png"): + output_filename += ".png" + + # Create a QR code object + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=0, + ) + + # Add the input data to the QR code object + qr.add_data(input_text) + + # Make the QR code + qr.make(fit=True) + + # Create an image object to store the generated QR code + img = qr.make_image(fill_color="black", back_color="white") + + # Save the QR code image to a file + img.save(output_filename) + + +if __name__ == "__main__": + # Set up the argument parser + parser = argparse.ArgumentParser(description="Generate a QR code from input text.") + parser.add_argument("-i", "--input", required=True, help="Text to be embedded in the QR code.") + parser.add_argument("-o", "--output", required=True, help="Filename for the output image.") + + # Parse the command-line arguments + args = parser.parse_args() + + # Call the main function with the provided arguments + main(args.input, args.output) \ No newline at end of file