-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQR Code - Image.py
46 lines (34 loc) · 1.06 KB
/
QR Code - Image.py
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
44
45
46
# import modules
import qrcode
from PIL import Image
# taking image which user wants
# in the QR code center
Logo_link = "C://Users//Chetan 696//Downloads//Chetan.jpg"
logo = Image.open(Logo_link)
# taking base width
basewidth = 150
# adjust image size
wpercent = (basewidth/float(logo.size[0]))
hsize = int((float(logo.size[1])*float(wpercent)))
logo = logo.resize((basewidth, hsize), Image.Resampling.LANCZOS)
QRcode = qrcode.QRCode(
error_correction=qrcode.constants.ERROR_CORRECT_H
)
# taking url or text
url = "https://www.linkedin.com/in/chetan-gudditi-922b38272/"
# adding URL or text to QRcode
QRcode.add_data(url)
# generating QR code
QRcode.make()
# taking color name from user
QRcolor = 'Blue'
# adding color to QR code
QRimg = QRcode.make_image(
fill_color=QRcolor, back_color="white").convert('RGB')
# set size of QR code
pos = ((QRimg.size[0] - logo.size[0]) // 2,
(QRimg.size[1] - logo.size[1]) // 2)
QRimg.paste(logo, pos)
# save the QR code generated
QRimg.save('My_LinkedIn.png')
print('QR code generated!')