pyquirc 
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyquirc-0.2.0.post1.tar.gz
(58.9 kB
view details)
File details
Details for the file pyquirc-0.2.0.post1.tar.gz.
File metadata
- Download URL: pyquirc-0.2.0.post1.tar.gz
- Upload date:
- Size: 58.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91cfa5ab076b7764903b263f4362cd78fefbf1dcda3921e624d52e02123f43f5
|
|
| MD5 |
de81dd0952fe5ddcdca3799055d9cb11
|
|
| BLAKE2b-256 |
c69ba68a48fa3873d56380a04c498af26e679ac637376f7056697da607f99cca
|