Read saved QR images
Pass PNG, JPEG, WebP or GIF bytes into 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 using the core Rust crate behind every QR Code AI scanner binding.
Pass PNG, JPEG, WebP or GIF bytes into ImageInput::encoded() to decode URLs, text and structured payloads locally.
Feed raw pixel buffers via ImageInput::rgba8() to avoid image-format roundtrips when decoding camera or video streams.
Read detections, physical occurrences, QR scannability scores and trace.budget_exhausted directly from strongly typed Rust structs.
Add the crate with Cargo, decode encoded PNG bytes in process and print the extracted QR text.
Use Rust 1.88 or newer and add qrcode-barcode-scanner on crates.io to your Cargo project. Complete API docs are available on docs.rs.
The crate links the scanning engine straight into your binary with no external CLI executable or outbound network calls.
cargo add qrcode-barcode-scanner
Import the crate module in Rust source as qrcode_barcode_scanner (using underscores).
Compiled symbology readers follow your enabled Cargo features; call the capabilities API to inspect active readers.
Build a Scanner with ScanProfile::Full, pass encoded image bytes via ImageInput::encoded and keep QR detections (Symbology::QrCode). Inspect report.trace.budget_exhausted and content.charset whenever byte-exact payload handling 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)
}
Pick ScanProfile::Frame for fast decode-only scans, ScanProfile::Fast for lighter scoring or ScanProfile::Full for the deepest pre-processing ladder.
Use ImageInput::rgba8 for raw pixel frames and ScanConfig.formats to run only the symbologies you need.
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 collapse into one detection entry with multiple occurrences.
An image with no QR code returns Ok with an empty detections vector rather than an Err. Invalid inputs (QRS-001 to QRS-004), cancellation (QRS-005) and invalid options (QRS-006) return an Err you can branch on via err.code().
Multi-engine core. The crate pairs rxing and rqrr in a deterministic ladder, handles PNG, JPEG, WebP, GIF and raw RGBA8 buffers, and exposes ScanConfig.formats to run only your required readers.
Budgets and payload fidelity. Pass None for budget_ms to run unbounded scans; treat a report as 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 images fail with QRS-002 or QRS-003, while invalid options (such as a zero Limits cap) fail pre-decode with QRS-006. Current releases ship under the MIT licence (with Apache-2.0 notices in LICENSING.md); read the Rust crate README and Rust API guide.
Official crate guides, ScanReport specification and licensing references.
Cargo setup, Rust toolchain, RGBA frames, scoring, budgets, errors and licensing.
It is QR Code AI’s open-source MIT-licensed Rust crate (qrcode-barcode-scanner) that underpins the entire scanner family. It decodes QR codes, Micro QR, rMQR and 16 barcode formats directly in process and returns a typed ScanReport carrying decoded content, measured geometry and QR scannability diagnostics.
Rust 1.88 or later is required. Add it via cargo add qrcode-barcode-scanner and import the library in code as qrcode_barcode_scanner.
Yes. Supply encoded PNG, JPEG, WebP or GIF bytes through ImageInput::encoded, or feed raw RGBA pixel buffers directly via ImageInput::rgba8 to skip any image-format roundtrip.
The Full and Fast profiles calculate a software QR scannability score and actionable hints based on measured image properties. Frame omits scoring, and score is typed as Option where None means unmeasured, never zero. Software diagnostics do not certify printed labels in place of a hardware verifier.
Each profile defines a default time budget; set budget_ms to None for an unbounded scan, and check report.trace.budget_exhausted == Some(false) before treating an empty list as final. Populate ScanConfig.formats to execute only the readers your workflow needs.
An image with no 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 you can match via err.code().
No. Decoding runs 100% locally inside your Rust 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 ship under the MIT licence, allowing commercial and proprietary deployment provided copyright and licence notices are preserved (see LICENSING.md for third-party Apache-2.0 notices). SDK usage is independent of QR Code AI’s paid creation plans and seven-day Premium trial.