-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpictureQRCodeGenerator.py
More file actions
43 lines (31 loc) · 941 Bytes
/
pictureQRCodeGenerator.py
File metadata and controls
43 lines (31 loc) · 941 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
40
41
42
#pip install Pillow
#pip install qrcode
import qrcode
from PIL import Image
Logo_link='googlelogo.jpg'
#image for centre of QR code
logo = Image.open(Logo_link)
#base width of 100
basewidth=100
#adjusting image size
wpercent=(basewidth/float(logo.size[0]))
hsize=int((float(logo.size[1]*float(wpercent))))
logo=logo.resize((basewidth,hsize), Image.ANTIALIAS)
QRcode=qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H)
#url or text for QR code
url = 'https://www.google.com/'
#adding URL or text to the QR code
QRcode.add_data(url)
#generate QR code
QRcode.make()
#input colour of QR code
QRcolor='#89E8F6'
#add colour 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 QR code as Name
QRimg.save('QRCodeName.png')
print ('QR code generated!')