Read label images
Pass PNG, JPEG, WebP or GIF bytes through ImageInput::encoded(). A Code 128 label encoding STOCK-4827 returns that exact string.
crates.io
Rust 1.88+
1D + 2D
MIT
Decode 1D retail, warehouse and 2D matrix labels in process with the Rust crate behind QR Code AI’s scanner bindings.
Pass PNG, JPEG, WebP or GIF bytes through ImageInput::encoded(). A Code 128 label encoding STOCK-4827 returns that exact string.
Supply raw pixel buffers via ImageInput::rgba8() for camera streams or video pipelines without an image-encoding roundtrip.
Read each detection’s Symbology enum and content.text string so leading zeros survive, then query your own inventory database.
Add the crate with Cargo, filter barcode symbologies in process and return exact identifier strings.
Use Rust 1.88 or later and add qrcode-barcode-scanner on crates.io to your Cargo project. Full API docs are published on docs.rs.
The crate compiles the multi-format engine directly into your binary with no external CLI executable or hosted lookup calls.
cargo add qrcode-barcode-scanner
Import the module in Rust as qrcode_barcode_scanner (with underscores).
Default features compile all 16 barcode symbologies plus QR Code, Micro QR and rMQR.
Build a Scanner with ScanProfile::Frame, pass encoded label bytes via ImageInput::encoded and keep the barcode symbologies your workflow needs. You can also set ScanConfig.formats so only selected readers run.
To prepare a known test label, create a Code 128 barcode with Barcode Generator containing STOCK-4827 and test the exported PNG.
use qrcode_barcode_scanner::{ImageInput, ScanProfile, Scanner, Symbology};
fn read_barcodes(path: &str) -> Result<Vec<(Symbology, String)>, Box<dyn std::error::Error>> {
let bytes = std::fs::read(path)?;
let scanner = Scanner::builder().profile(ScanProfile::Frame).build();
let report = scanner.scan(ImageInput::encoded(&bytes))?;
let items = report
.detections
.iter()
.filter(|d| d.symbology != Symbology::QrCode)
.map(|d| (d.symbology, d.content.text.clone()))
.collect();
Ok(items)
}
Switch from ScanProfile::Frame to ScanProfile::Full when reading low-contrast, skewed or challenging label photos.
Check report.trace.budget_exhausted == Some(false) before treating an empty detections list as final.
For a Code 128 label encoding STOCK-4827, read_barcodes returns (Symbology::Code128, "STOCK-4827"). A UPC-A value such as 012345678905 stays a String so its leading zero is preserved.
A blank image or QR-only photo returns Ok(vec![]). Unreadable files or oversized images return an Err whose err.code() identifies QRS-001 through QRS-006.
Sixteen barcode formats. Decodes EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode (ISBN maps to ean13, GS1-128 to code128, ITF-14 to itf).
Strings, geometry and budgets. Always keep decoded values as strings to preserve leading zeros; linear barcodes may report endpoints rather than four corners. Use ScanConfig.formats to skip unused readers and set budget_ms to None for unbounded scans.
Limits and licensing. Oversized inputs fail with QRS-002 or QRS-003, while invalid options (such as a zero Limits cap) fail before decoding with QRS-006. Current releases are MIT-licensed (with Apache-2.0 notices in LICENSING.md); see the Rust crate README and Rust API guide.
Official package documentation, ScanReport specification and licensing references.
Cargo setup, barcode formats, leading zeros, RGBA frames, errors and licensing.
It is QR Code AI’s open-source MIT Rust crate (qrcode-barcode-scanner) for decoding 1D and 2D barcodes (and QR codes) directly in process. It powers the other language bindings and returns a typed ScanReport with symbology, exact strings, raw bytes and measured geometry.
With default features it reads 16 barcode formats: EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode, plus QR Code, Micro QR and rMQR. ISBN, GS1-128 and ITF-14 return ean13, code128 and itf.
Rust 1.88 or later is required. Pass encoded PNG, JPEG, WebP or GIF bytes with ImageInput::encoded, or pass raw RGBA pixel buffers with ImageInput::rgba8 to avoid image-format roundtrips.
No. The engine returns each encoded identifier, its Symbology and parsed GS1 payload fields when recognized. Preserve identifiers as strings so leading zeros survive, and query your own catalog or inventory database separately.
Yes. Configure ScanConfig.formats with the symbologies you want; no reader of another symbology runs, and report.trace.formats records the active filter. Leaving formats empty scans every compiled symbology.
No barcode found returns Ok with an empty detections list (confirm trace.budget_exhausted == Some(false) for a final result). Corrupt or oversized inputs, cancellation and invalid options return an Err with QRS-001 through QRS-006 on err.code().
No. Decoding runs entirely locally inside your Rust process with zero network requests, no QR Code AI account, no API key and no creation credits.
Yes. Current releases are published under the MIT license, allowing commercial and proprietary use while keeping copyright and license notices (see LICENSING.md for third-party Apache-2.0 notices). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.