-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
43 lines (36 loc) · 1.41 KB
/
Copy pathMain.py
File metadata and controls
43 lines (36 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import qrcode
from PIL import Image, ImageDraw, ImageFont
import tkinter as tk
from tkinter import simpledialog
def generate_qr_with_logo(data, filename="custom_qrcode.png"):
qr = qrcode.QRCode(version=5, box_size=10, border=2)
qr.add_data(data)
qr.make(fit=True)
qr_img = qr.make_image(fill="black", back_color="white").convert("RGBA")
img_size = qr_img.size
background = Image.new("RGBA", img_size, "white")
small_qr = qr_img.resize((50, 50))
for x in range(0, img_size[0], 60):
for y in range(0, img_size[1], 60):
background.paste(small_qr, (x, y), small_qr)
font = ImageFont.truetype("arial.ttf", 80)
draw = ImageDraw.Draw(background)
text = "FOLIX" # You Can Change This Example : Eric, Carl And Anything...
text_size = draw.textbbox((0, 0), text, font=font)
text_x = (img_size[0] - text_size[2]) // 2
text_y = (img_size[1] - text_size[3]) // 2
draw.text((text_x, text_y), text, font=font, fill="black")
final_img = Image.alpha_composite(background, qr_img)
final_img = final_img.convert("RGB")
final_img.save(filename)
print(f"✅ Custom QR code saved as {filename}")
def get_link():
root = tk.Tk()
root.withdraw()
link = simpledialog.askstring("QR Code Generator", "Enter a link:")
if link:
generate_qr_with_logo(link)
else:
print("❌ No link provided!")
if __name__ == "__main__":
get_link()