Online you may have met a lot of dynamic QR code, in addition to feeling very novel, perhaps you will ask how this is done? In fact, there are simple and complex, simple is to use a GIF image to make. Today, we'll show you how to make dynamic QR codes in Python.
The implementation is MYQR with a free Python library, where you can see:
https://pypi.org/pypi/MyQR/
To install first:
Pip Install MYQR
After the installation is complete, enter MYQR on the command line to view the help under use.
You can read it in English, I don't explain it much.
Once you have installed MYQR, you can use it on the command line.
Generate normal QR code:
? ~ MYQR Ilovepython
Line 16:mode:byte
succeed!
Check out your 2-h qr-code:/users/anderson/qrcode.png
Generated two-dimensional code:
Sweep it, it is indeed the few words.
If you want to control the file path and file name of the output, you can use-D to control the output file path, using the-N control file name, which can be. jpg,. png,. bmp,. gif.
If you want to control the error correction level and the side length of the QR code, you can use the-l to control the error correction level, the range is L, M, Q, H, ascending from left to right, using-V to control the length of the edge, the range is 1 to 40, the larger the number of side length larger.
Two-dimensional code with pictures
If you want to create an art QR code, you can use the-p parameter to specify the picture, which combines the QR code with the picture.
To combine the above image into a QR code, you can use the following command to generate:
MYQR anderson-p Downloads/monkey.png
Line 16:mode:byte
succeed!
Check out your 2-h qr-code:/users/anderson/monkey_qrcode.png
The result of the default build is black and white, and if you want to generate color, you can add the parameter-C.
? ~ MYQR anderson-p downloads/monkey.png-c-N monkeycolor.png
Line 16:mode:byte
succeed!
Check out your 2-h qr-code:/users/anderson/monkeycolor.png
In addition, if you want the contrast and brightness of the picture, you can use the parameter-con to control the picture contrast, 1.0 for the original picture, the smaller value to indicate the lower contrast, the greater the converse. The default is 1.0, using the parameter-bri to adjust the brightness of the picture, and the remaining usage and value are the same as-con.
Dynamic GIF Two-dimensional code
If you want to generate a dynamic GIF QR code, the way with the above image of the two-dimensional code generation is no different, just convert the original png/.jpg picture into GIF.
Get a GIF on the internet first, find a Papi here.
Transcoding:
? ~ MYQR papi-c-P downloads/papi.gif
It may take a while, please wait for minutes ...
Line 16:mode:byte
succeed!
Check out your 1-h qr-code:/users/anderson/papi_qrcode.gif
Using in a Python program
In addition to being able to use MYQR on the command line, it can be used in a Python program, first applied, and then called.
From MYQR import MYQR
Import OS
Well, today's introduction is here, if you like, just a praise!
Incoming groups: 125240963 to get dozens of sets of PDFs OH
Use Python to generate the art QR code, how to make your QR code unique?