-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_qrcode.py
More file actions
39 lines (28 loc) · 921 Bytes
/
Copy pathgenerate_qrcode.py
File metadata and controls
39 lines (28 loc) · 921 Bytes
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
import qrcode
def generate_qr_code():
"""
Generate a QR code and save it as an image.
:return:
"""
print("####### Create a QR-Code with python #######")
# qr = _qrcode.QRCode(
# version=1,
# error_correction=_qrcode.constants.ERROR_CORRECT_L,
# box_size=10,
# border=4
# )
# Data to encode
data = "http://wtechitsolutions.com/"
# Creating an instance of QRCode class
qr = qrcode.QRCode(version=1, box_size=10, border=5)
# Adding data to the instance 'qr'
qr.add_data(data)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
# Save the image
file_path = "../output/MyQRCode.png"
img.save(file_path)
print(f"QR code generated and saved to {file_path}")
img.show() # This will open the image using the default image viewer
if __name__ == "__main__":
generate_qr_code()