• Stars
    star
    504
  • Rank 87,537 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

QArt Python Implementation.

PyQArt - QArt Python implementation

中文版 README

introduction

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):

QArt Example

This repo is Python implementation of it.

Install

pip install pyqart

Note: Support Python3 only, please make sure you are using pip of Python3.

Usage

For code reuse, I split the lib to two part. One for generate normal QrCode, another for generate QArt.

The Qr Part

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.

qr code: hello world

If you want show it in terminal, just don't provide -o option:

pyqr "Hello World"

Then you will see:

qr in terminal: hello world

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.

The Art Part

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.

Use it in your codes as a module

Documentation is in preparation.

Gallery

python.org(used -d option, means dithering, see help message for more info.)

github.com

bilibili.com (An ACG videos website)

Halftone and HalfArt support

Halftone support added in version 0.1.0, and I made another new method which combined Halftone and QArt, so I call it HalfArt temporarily.

Arguments for all methods

The following code shows arguments to get output image of all kind of method:

from pyqart import QArtist, QrHalftonePrinter, QrImagePrinter, QrPainter

QR_VERSION = 10
POINT_PIXEL = 3

artist = QArtist('http://www.nankai.edu.cn/', 'example.jpg', QR_VERSION)
painter = QrPainter('http://www.nankai.edu.cn/', QR_VERSION)
artist_data_only = QArtist('http://www.nankai.edu.cn/', 'example.jpg',
                           QR_VERSION, only_data=True)

# normal
QrImagePrinter.print(painter, path='normal.png', point_width=POINT_PIXEL)
# Halftone
QrHalftonePrinter.print(painter, path='halftone.png', img='example.jpg',
                        point_width=POINT_PIXEL, colorful=False)
# Halftone colorful
QrHalftonePrinter.print(painter, path='halftone-color.png', img='example.jpg',
                        point_width=POINT_PIXEL)
# Halftone pixel
QrHalftonePrinter.print(painter, path='halftone-pixel.png', img='example.jpg',
                        point_width=POINT_PIXEL, colorful=False,
                        pixelization=True)
# QArt
QrImagePrinter.print(artist, path='qart.png', point_width=POINT_PIXEL)
# QArt data only
QrImagePrinter.print(artist_data_only, path='qart-data-only.png',
                     point_width=POINT_PIXEL)
# HalfArt
QrHalftonePrinter.print(artist, path='halfart.png', point_width=POINT_PIXEL)
# HalfArt data only
QrHalftonePrinter.print(artist_data_only, path='halfart-data-only.png',
                        point_width=POINT_PIXEL)

Result example for all method

Halftone Halftone colorful Halftone pixel
QArt QArt data only
HalfArt HalfArt data only

TODO

  • Make QrPainter decided argument by itself.
  • Art part
  • CLI
  • Package
  • Halftone support
  • self-made HalfArt method
  • GUI
  • Use Cython to accelerate Reed-Solomon error correction
  • Docs
  • Tests

Other Implementation

Acknowledgements

  • All credit goes to Russ Cos, Thanks for his article and implement.
  • Thanks for qart4j project by dieforfree,which helps me so much on how to implement the art part.
  • Thanks to a series of articles named QR Code Tutorial in thonky.com, It's very detailed. Whenever I faced problem about encoding or error correction, I will go to it for help.
  • Thanks to the Python programing language。

LICENSE

MIT.

See LICENSE.

More Repositories

1

zhihu-py3

[不再维护] 后继者 zhihu-oauth https://github.com/7sDream/zhihu-oauth 已被 DMCA,亦不再开发,仅提供代码存档:
Python
1,038
star
2

rikka

A simple image share system in go.
Go
208
star
3

fontfor

Find fonts which can show a specified character and preview them in terminal or browser.
Rust
162
star
4

torrent_parser

A .torrent file parser and creator for both Python 2 and 3
Python
149
star
5

django-intro-zh

Django 官方文档的 intro 部分的中文翻译
137
star
6

scp-pdf

SCP 基金会中文 Wiki 文档集,下载:https://github.com/7sDream/scp-pdf/releases
TeX
83
star
7

remda

Learn Ray Tracing in One Weekend series using Rust.
Rust
62
star
8

jellyap

Create a WiFi AP with transparent proxy quickly
Shell
49
star
9

qqqfome

Thank-you-follow-me Ha Ha Ha!
Python
42
star
10

tui-markup

markup langauge for terminal styled text
Rust
41
star
11

danmacu

自用 Bilibili 弹幕姬 for macOS
Python
41
star
12

certbot-dns-challenge-cloudflare-hooks

Simple scripts I use to auto renew my Let's encrypt wildcard SSL cert.
Shell
39
star
13

fonts-and-layout-zhCN

《Fonts and Layout for Global Scripts》中文版。一本关于字体设计、Unicode和计算机中复杂文本处理的免费书籍。
Typst
36
star
14

kd100

由于快递 100 接口的问题,目前脚本不可用,是否能修复取决于快递 100 官网是否恢复。详情请看 Issue #3。
Python
28
star
15

amiya

experimental middleware-based minimalism async HTTP server framework
Rust
22
star
16

0v0.link-blog

Blog, powered by django, sqlite, apache.
Python
15
star
17

moon-render

An experiment - render characters using moon emoji in shell 🌕️
C
14
star
18

firelomo

快速发送网页内容到 flomo 的火狐扩展
TypeScript
14
star
19

pixel-bird-jump

🐦 A small flappy-bird-like game demo by Godot engine
GDScript
13
star
20

which_fonts_support

This project will not update anymore, use https://github.com/7sDream/fontfor instead.
Python
12
star
21

nonebot-plugin-bam

Bilibili activity monitor plugin for nonebot.
Python
7
star
22

antarctica

Anatarctica maps based on leaflet.js, proj4leaflet and images from GIBS of NASA.
JavaScript
7
star
23

geko

GEneric Keep Order types for JSON (un)marshal.
Go
6
star
24

connex

A plumber game
Rust
5
star
25

gbc

基于OpenGL和GLUT的C++类库(OpenGL and GLUT Based Classes),写来学图形学的
C++
5
star
26

piano-emulator

A simple gui piano emulator, with Matlab.
HTML
4
star
27

coin

toss coin in the fish. 🌕🌖🌗🌘🌑🌒🌓🌔🌕
Shell
4
star
28

pyqt-piano-emulator

a piano emulator in windows by pyqt
Python
4
star
29

useful-files

some useful setting or other files
Shell
3
star
30

arbitrary

Rust
3
star
31

burz

Kaiheila bot framework for Rust
Rust
3
star
32

bgpview-cli

CLI tools for bgpview.io
Rust
2
star
33

typst-easy-pinyin

Write Chinese pinyin easily.
1
star
34

slog

Go
1
star
35

dotnes

[WIP] Yet another NES file parser
Rust
1
star
36

tui-markup-ansi-macro

A macro to generate styled ansi escape sequence from markup language
Rust
1
star
37

goodomain

A tiny toy to find good domain from your favorite word.
Svelte
1
star
38

nonebot-plugin-7s-roll

A roll dice plugin for nonebot
Python
1
star
39

qqbot-linger

My QQ Bot for personal use
Python
1
star