QR Code in Python
Python QR二维码生成器
It can generate common qr-code, black&white artistic qr-code, colorful artistic qr-code and animated qr-code.
可以生成普通二维码、黑白带图片的艺术二维码、彩色艺术二维码和动态二维码。
python myqr.py [-h]
[-v {1,2,3,...,40}]
[-l {L,M,Q,H}]
Words
-
Use argument
-hfor help.使用参数
-h来获得使用帮助。
#1 url
python myqr.py https://github.com-
Simplest way: Just input a URL or a sentence, then get your QR-Code in the current directory.
最简单的用法:在命令后输入链接或者句子作为参数,然后在程序的当前目录中产生相应的QR二维码图片。
#2 -v, -l
python myqr.py https://github.com -v 10 -l Q-
The default length of a side of QR-Code depends on both the numbers of words you input. And the default level (Error Correction Level) is H (the highest).
默认边长是取决于你输入的信息的长度,而默认纠错等级是最高级的H。
-
Customize size: If you want to control the length and the error-correction-level, use the
-vand-larguments. The-vrepresenting the length is from 1 to 40 that 1 means minimum and 40 means maximum. The-lrepresenting the level is one of L, M, Q and H that L means lowest and H means highest.自定义尺寸:如果想要控制边长和纠错水平就使用
-v和-l参数。使用-v来控制边长,范围是1至40,数字越大边长越大;使用-l来控制纠错水平,范围是L、M、Q、H,从左到右依次升高。
python myqr.py [-h]
[-v {1,2,3,...,40}]
[-l {L,M,Q,H}]
[-p picture_file]
[-c]
[-con contrast]
[-bri birghtness]
Words
-
arguments
-h,-vand-lis as mentioned above.参数
-h,-v和-l如上文述。
#1 -p
python myqr.py https://github.com -p github.jpg-
The
-pis to combine the QR-Code with the following picture which is at the same directory as the program. The resulting picture is black and white by default.参数
-p用来将QR二维码图像与一张同目录下的图片相结合,产生一张黑白图片。 -
Suggestion: If the size of the picture is large, you should choose a correct large
-vtoo instead of using the default one.建议在图片尺寸大的时候使用
-v的值也应该适当变大。
#2 -c
python myqr.py https://github.com -p github.jpg -c-
The
-cis to make the resulting picture colorized.加上参数
-c可以使产生的图片由黑白变为彩色的。
#3 -con, -bri
python myqr.py https://github.com -p github.jpg [-c] -con 1.5 -bri 1.6-
The
-conchanges the contrast of the picture that 1.0 means original image, lower values mean less contrast and higher mean more. Default: 1.0.参数
-con用以调节图片的对比度,1.0 表示原始图片,更小的值表示更低对比度,更大反之。默认为1.0。 -
The
-brichanges the brightness and the value is just like-con's.参数
-bri用来调节图片的亮度,其余用法和取值与-con相同。
The only one difference from Artistic QR-Code mentioned above is that you should input a image file in the format .gif. The you can get your black-and-white or colorful qr-code.
动态二维码与上述的带图片的二维码的生成方法没什么区别,你只要采用 .gif 格式的图片即可黑白或者彩色的动态二维码。
-
Use a square picture instead of a rectangle one.
请采用正方形的图片
-
If part of picture is transparent, the qr code will be like:
You can change it into white, then be like:
-
Numbers:
0~9数字 0 到 9
-
Letters:
a~z, A~Z大小写的英文字母
-
Common punctuations:
常用英文标点符号和空格
· , . : ; + - * / \ ~ ! @ # $ % ^ & ` [ ] ( ) ? _ { } | and (space)
- pillow
- numpy
- imageio
- Linux, Python 3
- Windows, Python 3