A tiny QR code encoder in one file of pure Python. It outputs SVG and PNG, needs no dependencies (not even Pillow) and runs on Python 3.8+.
It was written for the review-link poster on iverium.nl/google-reviewlink-maken, which runs on a server with a plain Python install.
- Byte mode (UTF-8), error correction M or Q, versions 1-15 (up to 412 bytes at level M, 292 at Q)
- Automatic version and mask selection with the standard penalty rules
- SVG output with one path and crisp edges, so it scales to any size; PNG output via
zlibonly - Verified module-for-module against python-qrcode for every mask, and decoded back with zxing-cpp. Both checks run in CI.
pip install git+https://github.com/Iverium/tinyqrOr just copy tinyqr/qr.py into your project.
tinyqr "https://www.iverium.nl" # print it in the terminal
tinyqr "https://www.iverium.nl" -o code.svg
tinyqr "https://www.iverium.nl" -o code.png --scale 10 --ecl Mimport tinyqr
tinyqr.svg("https://www.iverium.nl") # '<svg xmlns=... viewBox="0 0 37 37" ...>'
tinyqr.png("https://www.iverium.nl", scale=10) # PNG bytes
tinyqr.encode("hello", ecl="Q") # list of rows of bools (True = dark), no quiet zonesvg() takes ecl, border (quiet zone, default 4) and css_class. png() takes ecl, border and scale (pixels per module). Text that doesn't fit in version 15 raises ValueError.
You often need a QR code in a place where installing packages is a hassle: a small web app on an old server, a script or a serverless function. tinyqr is about 300 lines with no imports beyond struct and zlib. Its structure follows Project Nayuki's well-known reference implementation. For numeric/alphanumeric modes, kanji or versions above 15, use segno or python-qrcode.
tinyqr maakt QR-codes als SVG of PNG met alleen de Python-standaardbibliotheek. Wij gebruiken het voor de gratis Google-reviewlink en QR-poster. Combineer het met google-reviewlink om in één stap een QR-code naar uw Google-reviews te maken.
MIT. Made by Iverium Software, web development in Groningen and Drenthe (NL).