Skip to main content

pyquirc PyPI version

Python and C++ bindings for the quirc library, created using pybind11.

Installation

The package is on pypi, just

$ pip install pyquirc

There is an older, no longer maintained package quirc, not to be confused.

Example

# we read images using pillow, numpy arrays do also work
from PIL import Image, ImageOps
import quirc

img = Image.open("resources/helloworld.png")

# we need to convert to 8-bit grayscale for quirc
img = ImageOps.grayscale(img)

# Images must either have `tobytes()`, `width` and `height` like PIL images
# or support the 2d buffer protocal, both with data type uint8 (8-Bit Grayscale)
decoded_codes = quirc.decode(img)

print(f'Found {len(decoded_codes)} qr code(s) in the image')

for code, data in decoded_codes:
    print(code)
    print(data)

Output:

Found 1 qr code(s) in the image
Code(size=21, corners=[Point(40, 40), Point(250, 40), Point(250, 250), Point(40, 250)])
Data(payload=b'Hello, World!', version=1, data_type=DataType.BYTE, eci=ECI.UNDEFINED, ecc_level=ECCLevel.M, mask=5)

On the Command Line

This package also installs the tool pyquirc_decode, which will use pillow as above and decode the QR code in the given image.

The payloads of each decoded qr code will be printed to stdout, one per line:

$ pyquirc_decode resources/helloworld.png -v
INFO Found 1 qr code in image
INFO --- Payload 1 ---
Hello, World!

The log messages come on stderr, so piping the the output will only pipe the payloads, not the log output.

Release files for pyquirc 0.2.0.post1

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

Source distribution (sdist)

Source distribution for pyquirc 0.2.0.post1
File Size Uploaded
pyquirc-0.2.0.post1.tar.gz 58.9 kB Details

Release files / pyquirc-0.2.0.post1.tar.gz

Download URL pyquirc-0.2.0.post1.tar.gz
Size 58.9 kB
Tags Source
SHA-256 checksum
How to use checksums
91cfa5ab076b7764903b263f4362cd78fefbf1dcda3921e624d52e02123f43f5
BLAKE2b-256 checksum
How to use checksums
c69ba68a48fa3873d56380a04c498af26e679ac637376f7056697da607f99cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.2.0.post1 This release

1 release file

0.2.0

1 release file

0.1.0

1 release file

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