Skip to content

Commit 79a41f5

Browse files
committed
edited generate/read qr code tutorial
1 parent 2374634 commit 79a41f5

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import qrcode
2+
import numpy as np
3+
# data to encode
4+
data = "https://www.thepythoncode.com"
5+
6+
# instantiate QRCode object
7+
qr = qrcode.QRCode(version=1, box_size=10, border=4)
8+
# add data to the QR code
9+
qr.add_data(data)
10+
# compile the data into a QR code array
11+
qr.make()
12+
# print the image shape
13+
print("The shape of the QR image:", np.array(qr.get_matrix()).shape)
14+
# transfer the array into an actual image
15+
img = qr.make_image(fill_color="white", back_color="black")
16+
# save it to a file
17+
img.save("site_inversed.png")
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
opencv-python
2-
qrcode
2+
qrcode
3+
numpy
-243 Bytes
Loading
455 Bytes
Loading

0 commit comments

Comments
 (0)