init commit
This commit is contained in:
commit
760fbf68e7
4 changed files with 44 additions and 0 deletions
42
main.py
Normal file
42
main.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import argparse
|
||||||
|
import qrcode
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
def generate_qr_code(url, name):
|
||||||
|
qr = qrcode.QRCode(
|
||||||
|
version=1,
|
||||||
|
error_correction=qrcode.constants.ERROR_CORRECT_H,
|
||||||
|
box_size=50,
|
||||||
|
border=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
qr.add_data(url)
|
||||||
|
qr.make(fit=True)
|
||||||
|
|
||||||
|
img = qr.make_image(fill_color="black", back_color="white")
|
||||||
|
|
||||||
|
overlay = Image.open("static/rs_koc.webp")
|
||||||
|
|
||||||
|
if overlay.mode != 'RGBA':
|
||||||
|
overlay = overlay.convert('RGBA')
|
||||||
|
if img.mode != 'RGBA':
|
||||||
|
img = img.convert('RGBA')
|
||||||
|
|
||||||
|
img.paste(overlay, (420, 420), overlay)
|
||||||
|
|
||||||
|
output_path = f"output/{name}.png"
|
||||||
|
img.save(output_path)
|
||||||
|
|
||||||
|
print(f"QR Code generated at: {output_path}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('url', help="URL for the QR code")
|
||||||
|
parser.add_argument('name', help="Name of the file, do not include extension")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
generate_qr_code(args.url, args.name)
|
||||||
BIN
output/test.png
Normal file
BIN
output/test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
pillow==12.1.1
|
||||||
|
qrcode==8.2
|
||||||
BIN
static/rs_koc.webp
Normal file
BIN
static/rs_koc.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Loading…
Reference in a new issue