Read saved QR images
Pass PNG, JPEG, WebP or GIF bytes through ImageInput::encoded() to decode URLs, text and structured payloads locally.
crates.io
Rust 1.88+
In-process
MIT
Decode encoded images or raw RGBA frames in process with the Rust crate behind every QR Code AI scanner binding.
Pass PNG, JPEG, WebP or GIF bytes through ImageInput::encoded() to decode URLs, text and structured payloads locally.
Supply raw pixel buffers via ImageInput::rgba8() to skip image-format encoding when processing camera or video frames.
Read detections, physical occurrences, QR scannability scores and trace.budget_exhausted directly from strongly typed Rust structs.
Add the crate with Cargo, scan encoded PNG bytes in process and print decoded QR text.
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 core scanning engine directly into your binary, with no external CLI binary or network requests.
cargo add qrcode-barcode-scanner
Import the library module in Rust code as qrcode_barcode_scanner (with underscores).
Compiled symbology readers depend on the crate features you select; use the capabilities API to inspect active readers.
Build a Scanner with ScanProfile::Full, pass image bytes through ImageInput::encoded and keep QR code detections (Symbology::QrCode). Check report.trace.budget_exhausted and content.charset when exact payload fidelity matters.
use qrcode_barcode_scanner::{ImageInput, ScanProfile, Scanner, Symbology};
fn read_qr_image(path: &str) -> Result<Vec<String>, Box<dyn std::error::Error>> {
let bytes = std::fs::read(path)?;
let scanner = Scanner::builder().profile(ScanProfile::Full).build();
let report = scanner.scan(ImageInput::encoded(&bytes))?;
let urls = report
.detections
.iter()
.filter(|d| d.symbology == Symbology::QrCode)
.map(|d| d.content.text.clone())
.collect();
Ok(urls)
}
Use ScanProfile::Frame for fast decoding without a QR quality score, ScanProfile::Fast for lighter scoring or ScanProfile::Full for the deepest preprocessing ladder.
Use ImageInput::rgba8 for raw pixel frames and ScanConfig.formats to restrict decoding to specific symbologies.
For a QR image encoding https://qrcode-ai.com/, read_qr_image returns Ok(vec!["https://qrcode-ai.com/"]). Multiple physical copies of the same payload share one detection entry with several occurrences.
An image with no QR code returns Ok with an empty detections vector, not an Err. Invalid inputs (QRS-001 to QRS-004), cancellation (QRS-005) and invalid options (QRS-006) return an Err you can match via err.code().
Multi-engine core. The crate combines rxing and rqrr in a deterministic ladder, supports PNG, JPEG, WebP, GIF and raw RGBA8 inputs, and exposes ScanConfig.formats to run only the readers you need.
Budgets and payload fidelity. Set budget_ms to None for unbounded scans; a report is final only when trace.budget_exhausted is Some(false). Treat score None as unmeasured, never zero, and read content.raw when content.charset is unknown.
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, Rust version, RGBA frames, scoring, budgets, errors and licensing.
It is QR Code AI’s open-source MIT Rust crate (qrcode-barcode-scanner) that powers the entire scanner family. It decodes QR codes, Micro QR, rMQR and 16 barcode formats directly in process and returns a typed ScanReport with decoded content, geometry and QR scannability diagnostics.
Rust 1.88 or later is required. Install it with cargo add qrcode-barcode-scanner and import the crate as qrcode_barcode_scanner.
Yes. Pass encoded PNG, JPEG, WebP or GIF bytes through ImageInput::encoded, or pass raw RGBA pixel buffers directly via ImageInput::rgba8 to avoid an image-format roundtrip.
The Full and Fast profiles compute a software QR scannability score and actionable hints derived from real measurements. Frame skips scoring, and score is an Option where None means unmeasured, never zero. Software diagnostics do not certify printed labels with a hardware verifier.
Each profile has a default time budget; set budget_ms to None for an unbounded scan, and confirm report.trace.budget_exhausted == Some(false) before treating an empty result as final. Set ScanConfig.formats to run only the readers you need.
An image without a code returns Ok with an empty detections vector. Unreadable or oversized inputs (QRS-001 to QRS-004), cancellation (QRS-005) and invalid options such as a zero Limits cap (QRS-006) return an Err where you can branch on err.code().
No. Decoding runs 100% locally in process with zero network requests, no QR Code AI account, no API key and no creation credits. Decoded URLs are never fetched automatically.
Yes. Current releases are published under the MIT license, allowing commercial and proprietary use while preserving 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.