
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
pyrxing is a fast, dependency-free Python barcode/QR code reader built using zxing-cpp Rust bindings via PyO3.
This library offers efficient barcode scanning in pure Python environments, with pre-built native wheels — including full support for Alpine Linux and musl
-based systems where the official zxing-cpp Python package requires additional build steps.
read_barcode
and read_barcodes
musllinux
wheels available (no build required).pyi
stub filesx86_64
, aarch64
x64
, x86
Python 3.11+
Install with pip:
pip install pyrxing
Recommended for Alpine Linux/musl environments: While the official zxing-cpp Python package requires building from source on musl-based systems, pyrxing provides pre-built wheels for immediate installation.
pyrxing delivers excellent performance across a comprehensive range of barcode formats, with particularly strong advantages in multiple barcode detection scenarios:
Performance Summary:
read_barcode()
- Single Barcode DetectionFormat | pyrxing | zxing-cpp | Improvement |
---|---|---|---|
UPC-E | 555.9 | 710.8 | 28% faster |
Data Matrix | 260.0 | 330.9 | 27% faster |
EAN-8 | 881.8 | 1048.2 | 19% faster |
UPC-A | 1159.5 | 1358.5 | 17% faster |
EAN-13 | 1161.7 | 1328.4 | 14% faster |
Code 39 | 1063.5 | 1212.8 | 14% faster |
ITF | 336.2 | 382.3 | 14% faster |
Code 128 | 2272.2 | 2541.0 | 12% faster |
Codabar | 415.1 | 468.1 | 13% faster |
MaxiCode | 947.5 | 1026.0 | 8% faster |
PDF417 | 369.6 | 400.1 | 8% faster |
Aztec | 85.9 | 92.8 | 7% faster |
DX Film Edge | 302.1 | 314.1 | 4% faster |
QR Code | 294.5 | 292.3 | 1% slower |
Code 93 | 281.3 | 276.3 | 2% slower |
Micro QR | 75.4 | 73.1 | 3% slower |
rMQR | 84.6 | 84.3 | 0% (tied) |
DataBar | 198.5 | 196.9 | 1% slower |
DataBar Exp. | 358.3 | 356.1 | 1% slower |
DataBar Ltd. | 196.6 | 186.6 | 5% slower |
read_barcodes()
- Multiple Barcode DetectionFormat | pyrxing | zxing-cpp | Improvement |
---|---|---|---|
UPC-A | 4500.0 | 4817.0 | 7% faster |
Codabar | 1248.8 | 1341.4 | 7% faster |
EAN-8 | 2683.3 | 2854.9 | 6% faster |
UPC-E | 1962.7 | 2062.0 | 5% faster |
ITF | 1039.5 | 1085.9 | 4% faster |
Code 39 | 3078.0 | 3206.5 | 4% faster |
PDF417 | 851.1 | 883.7 | 4% faster |
EAN-13 | 4566.9 | 4739.6 | 4% faster |
Code 128 | 7769.5 | 8014.2 | 3% faster |
Aztec | 558.3 | 575.1 | 3% faster |
DX Film Edge | 1572.9 | 1609.0 | 2% faster |
MaxiCode | 2509.3 | 2561.3 | 2% faster |
Data Matrix | 1002.5 | 1082.3 | 8% faster |
rMQR | 466.5 | 471.9 | 1% faster |
QR Code | 2203.3 | 2205.6 | 0% faster |
Micro QR | 407.0 | 407.8 | 0% faster |
Code 93 | 950.5 | 937.8 | 1% slower |
DataBar | 670.4 | 666.9 | 1% slower |
DataBar Exp. | 1300.4 | 1279.2 | 2% slower |
DataBar Ltd. | 629.3 | 620.7 | 1% slower |
Test Images: Located in pyrxing/assets/
directory:
test_codabar.png
, test_code39.png
, test_code93.png
, test_code128.png
, test_ean8.png
, test_ean13.png
, test_itf.png
, test_upc_a.png
, test_upc_e.png
, test_data_bar.png
, test_data_bar_expanded.png
, test_data_bar_limited.png
test_qr_code.png
, test_micro_qr.png
, test_rmqr.png
, test_aztec.png
, test_data_matrix.png
, test_pdf417.png
, test_maxi_code.png
test_dx_film_edge.png
Reproduce benchmarks: See pyrxing/benchmark.py
for the complete benchmark script.
from pyrxing import read_barcode, read_barcodes
# Read a single barcode from an image path
barcode = read_barcode("example.png")
# Read multiple barcodes from an image
barcodes = read_barcodes("example.png")
# Optionally filter by barcode format
barcodes = read_barcodes("example.png", formats=['QRCode'])
You can also pass an object that conforms to the ImageProtocol
instead of a path.
from pyrxing import read_barcode
from PIL import Image
# Read a single barcode from PIL.Image.Image object
barcode = read_barcode(Image.open("example.png"))
For full API and type hints, see pyrxing.pyi
or use your IDE's autocomplete.
from typing import Any, Literal, Protocol
BarcodeFormat = Literal[
"Aztec",
"Codabar",
"Code39",
"Code93",
"Code128",
"DataBar",
"DataBarExpanded",
"DataBarLimited",
"DataMatrix",
"EAN8",
"EAN13",
"ITF",
"MaxiCode",
"PDF417",
"QRCode",
"UPCA",
"UPCE",
"MicroQRCode",
"RMQRCode",
"DXFilmEdge",
]
class ImageProtocol(Protocol):
@property
def width(self) -> int: ...
@property
def height(self) -> int: ...
def tobytes(self) -> bytes:
"""return pixel data as byte array"""
def convert(self, mode: str) -> Any: ...
def load(self): ...
class BarcodeDecodeError(Exception): ...
class ImageError(Exception): ...
class Point:
@property
def x(self) -> float: ...
@property
def y(self) -> float: ...
class DecodeResult:
@property
def text(self) -> str: ...
@property
def points(self) -> list[Point]: ...
@property
def format(self) -> str: ...
def read_barcode(image: str | ImageProtocol, *, formats: list[BarcodeFormat] | None = None) -> DecodeResult | None: ...
def read_barcodes(image: str | ImageProtocol, *, formats: list[BarcodeFormat] | None = None) -> list[DecodeResult]: ...
Apache License 2.0
FAQs
A barcode reader extension module using zxing-cpp and pyo3
We found that pyrxing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.