In this tutorial, we will introduce how to create a qrcode using python pillow and qrcode library.
1.Install pillow and qrcode library
pip install qrcode pip install pillow
2.Creata a qrcode
import qrcode img = qrcode.make('test text') print(type(img)) print(img.size) # <class 'qrcode.image.pil.PilImage'> # (290, 290)
Here ‘test text‘ is the content in qrcode.
3.Save qrcode as to image
img.save('data/dst/qrcode_test.png')
Run this code, you will see this qrcode image:
We also can use opencv to decode qrcode. Here is a tutorial:
Detect and Decode a QRCode Image Using cv2.QRCodeDetector() in Python OpenCV