analitics

Pages

Saturday, July 2, 2022

Python 3.7.10 : Simple example with PyQRCode.

The pyqrcode module is a QR code generator that can automate most of the building process for creating QR codes.
The pypng python library is required to save and upload PNG images.
I had to install them both with the pip utility.
pip install pyqrcode
Collecting pyqrcode
  Using cached PyQRCode-1.2.1-py3-none-any.whl
Installing collected packages: pyqrcode
Successfully installed pyqrcode-1.2.1
WARNING: There was an error checking the latest version of pip.
...
pip install pypng
Collecting pypng
  Using cached pypng-0.0.21-py3-none-any.whl (48 kB)
Installing collected packages: pypng
Successfully installed pypng-0.0.21
WARNING: There was an error checking the latest version of pip.
Let's try some simple examples:
import pyqrcode
url = pyqrcode.create('https://ro.wikipedia.org/wiki/Utilizator:Catalin_Festila', error='H', mode='binary')
url.svg('uca-url.svg', scale=8)
url.eps('uca-url.eps', scale=2)
url.png('code.png', scale=5, module_color=[0, 0, 0, 128], background=[0, 0, 128])
url.show()
print(url.terminal(quiet_zone=1))
This is the result of this source code: