-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr-code.py
More file actions
22 lines (15 loc) · 951 Bytes
/
qr-code.py
File metadata and controls
22 lines (15 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import qrcode
data = input("Enter text or URL: ") # asks for user input
# create QR code
qr = qrcode.QRCode(
version=1, #it gives us the smallest qr code as for a better readability
error_correction=qrcode.constants.ERROR_CORRECT_H, # it means qr can handle 30% damage
box_size=8, #it gives us a smaller box which is good for screenshots or images
border=4 #it will give us a border of 4 boxes (default is 4)
)
qr.add_data(data) # it adds the text, URL, or any information which we want into the QR code
qr.make(fit=True) #it adjusts the size of the QR code according to the data
img = qr.make_image(fill_color="black", back_color="white") # it makes the image with colours
filename = input("Enter file name to save QR code: ") # asks for file name to save the QR code
img.save(filename + ".png") # saves the image as a PNG file
print("✅ QR Code saved as " + filename + ".png") # confirmation message