Create a dynamic two-dimensional code with a single line of Python code

On GitHub found a more interesting project, only one line of Python code can be quickly and easily generate ordinary two-dimensional code, art two-dimensional code (black and white / color) and animated GIF two-dimensional code.

See GitHub website: https://github.com/sylnsfar/qrcode

Usage is relatively simple, can be installed directly through the pip.

pip3 install myqr

  

The installation process is as follows: 

 

 

After installation is complete, you may generate a desired two-dimensional code based on the command instructions, myqr module parameters as follows:

 

The main parameters of translation is as follows:

-v: Defines the size of two-dimensional code, in the range of 1 to 40, depending on the size of the default content input

-l: definition of the two-dimensional code error correction rate, that is to say the two-dimensional code is still blocked portion is identified, four grades, namely L (7%), M (15%), Q (25%), H (30%), default is the highest level of H

-n: Custom two-dimensional code name

-d: Path Custom two-dimensional code

-con: Modify the image contrast, the default value is 1.0

-bri: modify the image brightness, the default value is also 1.0

1, an ordinary two-dimensional code

My blog address to generate two-dimensional code, use the following command:

myqr https://me.csdn.net/blog/m0_38106923

Two-dimensional code is automatically saved in the current directory, the default name for the qrcode.png.

 

 

Results are as follows: 

 

When the need to modify the name or path to generate two-dimensional code can be accomplished by a command, for example, to generate a two-dimensional code image Python3X.jpg, the path to the root directory in the E disk, the following instructions:

myqr https://me.csdn.net/blog/m0_38106923 -n Python3X.jpg -d E:

2, art two-dimensional code

 Sometimes in order to attract everyone's attention, the effect of ordinary two-dimensional code will be powerless. Art can be in the form of two-dimensional code generated is also very simple.

For example I find the Internet photos of Les Enfants Rebels combine my blog address, to generate two-dimensional code.

 

 Can to complete the parameter -p, the following instructions: 

myqr https://me.csdn.net/blog/m0_38106923 -p C:\Users\13450\Desktop\im1.png

  

Results are as follows: 

 

 

 

 The result is black and white, is not ideal, this time, we need to use another parameter -c, pictures for coloring, ordered as follows:

myqr https://me.csdn.net/blog/m0_38106923 -p C:\Users\13450\Desktop\im1.png -c

  

Results are as follows:

 

3, the dynamic two-dimensional code

Although the art of two-dimensional code pretty much, but we still can not achieve the purpose of the X installed, so, you can be a dynamic two-dimensional code.

Artistic way with the two-dimensional code as above, the only difference is that the picture must be a gif. The default is black and white, color two-dimensional code also need to add the parameter -c.

FIG blog address using the combination of a motion picture, to generate two-dimensional code.

Instructions are as follows:

myqr https://me.csdn.net/blog/m0_38106923 -p C:\Users\13450\Desktop\im1.gif -c

  

Results are as follows:

  

 

Guess you like

Origin www.cnblogs.com/pypypy/p/11897696.html