Skip to main content

bareqr - Bare headless QR code generator

bareqr was derived from python-qrcode. I removed all dependencies, console scripts, renderers, and made it headless.

bareqr is:

  • stateless
  • threadsafe
  • PEP-8 compliant
  • fully typed

Main features

There is just one feature: produce the matrix.

from bareqr import qrcode
from pprint import pprint

qr = qrcode("1234")

pprint(qr.rows)
>>>
[[1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1],
 [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
 [1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1],
 [1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1],
 ...
 [1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0]]

bareqr won't automatically split data to chunks of different types. You may split data manually:

qr = qrcode("1234", "HELLO", "world")

For each chunk bareqr will choose the correct data type: number, alphanumeric or bytes.

The automatic splitting is available as a separate utility:

from bareqr import optimal_chunks

chunks = optimal_chunks("1234HELLOworld", min_chunk=4)
qr = qrcode(*chunks)

qrcode has an internal global cache of precomputed blank QR codes. In bareqr this cache is external and opt-in:

cache = {}
qr1 = qrcode("1234", blanks_cache=cache)
qr2 = qrcode("5678", blanks_cache=cache)

Extra features

Ok, in fact bareqr is not completely headless. There are two utils to render QR as ascii or png. Treat them as handy extras.

from bareqr import qrcode, as_ascii, as_png
qr = qrcode("1234")

asc = as_ascii(qr, border=2, invert=True)
for row in asc:
    print(row)

png = as_png(qr, border=2, scale=4)
with open("qr.png", "wb") as f:
    f.write(png)

The png encoder is custom to avoid extra dependencies.

Metadata

Release files for bareqr 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bareqr 0.1.1
File Size Uploaded
bareqr-0.1.1.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bareqr 0.1.1
File Interpreter ABI Platform
bareqr-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.4 kB

Release files / bareqr-0.1.1.tar.gz

Download URL bareqr-0.1.1.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a66ea1efd9d21ab0b2520a8a1646c5338b94a9a26e596e020af3d75b7c26e311
BLAKE2b-256 checksum
How to use checksums
eaf2878c6c55d69da62a1b267e322490719e0fcc8a3ec9f96a69568f04707130
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / bareqr-0.1.1-py3-none-any.whl

Download URL bareqr-0.1.1-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fa0950bb4f330ae6ab1d2a844bb622620f553dcb0a8d9fe31ae06b9e6e02d87
BLAKE2b-256 checksum
How to use checksums
29defff6a2486c0084e4b53ae721c2f682fc4139578216ff9133bdec94a779b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page