7sDream / pyqart
- воскресенье, 7 августа 2016 г. в 03:12:47
Python
QArt Python Implementation.
QArt is a method of combining QrCode of an URL with any image, which was submitted in an article writen by Russ Cox on his personal website.
An Example(come from the article):
This repo is Python implementation of it.
pip install pyqart
Note: Support Python3 only, please make sure you are using pip of Python3.
For code reuse, I split the lib to two part. One for generate normal QrCode, another for generate QArt.
Use pyqr
CLI to create normal QrCode.
pyqr -p 5 -c 102 204 255 "Hello World!" -o qr.png
The options:
-p
for point size of QrQCode, by pixel, default is 3 pixel.-c
for color of point, default is black. Background color can be set with -g
option, default is white.If you want show it in terminal, just don't provide -o
option:
pyqr "Hello World"
Then you will see:
The actual result you will see depends on your font setting, I'm using Dejavu Sans Mono.
Yes, it is only useful for small QrCode.
Run pyqr -h
for more options and their effect.
Use pyqart
CLI to create QArt. It may take a long time, please be patient :)
This is an example that mix my blog url and my Github avatar:
pyqart -v 8 -c 102 204 255 "http://0v0.link/" photo.jpg -o qart.png
My Github avatar:
The QArt Code:
Not meet your expectations? Try -n
option to pick point at random(default is pick low-contrast region pixels first):
pyqart -n -c 102 204 255 -v 8 "http://0v0.link/" photo.jpg -o qart-n.png
Still not satisfied? Use -y
option to enhance the accuracy of the central region by giving up the control of the edge pixels:
-y
and -n
can be used at the same time, but no obvious improvement.
Note: because that -y
option will only use data block, ignore error correction block,it reduce many many many calculate. It has about 30x to 100x speed up compare with no -y
option case. So I strongly recommend using -y
option whenever you needn't make a full picture fitting.
Use -r
option to set rotation degree, The controllable data region can be changed into a horizontal area, it will make it easier to process very wide picture.
Run pyqart -h
for more options and their effect.
Documentation is in preparation.
python.org(used -d option, means dithering, see help message for more info.)
github.com
bilibili.com (An ACG videos website)
MIT.
See LICENSE.