-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr.py
More file actions
39 lines (32 loc) · 797 Bytes
/
qr.py
File metadata and controls
39 lines (32 loc) · 797 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
import pyqrcode
import png
import os
from PIL import Image
str = input("Enter the string: ")
qc = pyqrcode.create(str) #Generate QR code.
print("\nQR code generated...\n")
#Saving file.
x = 0
files = [f for f in os.listdir( os.curdir ) if os.path.isfile(f) ] #List files in PWD.
while(x==0):
x = 1
name = input("Save as? ")
svg = name + ".svg"
png = name + ".png"
#Check if file name is taken
for file in files:
if file == svg or file == png:
print("File name taken.Please use a different name.")
x = 0
break
#Save as svg file.
qc.svg(svg, scale = 8)
print("Saved as {}".format(svg))
#Save as png file.
qc.png(png, scale = 6)
print("Saved as {}".format(png))
#To show the QR Code
sh = input("Show code? (Y/N): ")
if sh == 'Y' or sh == 'y':
im = Image.open(png)
im.show()