Crates.io | qrism |
lib.rs | qrism |
version | 0.1.0 |
created_at | 2025-09-25 19:01:55.867926+00 |
updated_at | 2025-09-25 19:01:55.867926+00 |
description | A Rust library for generating and reading QR codes with Reed-Solomon error correction. Supports traditional monochromatic QR codes with additional experimental multicolor QR support for enhanced storage capacity. |
homepage | https://github.com/mohnishsalian0/qrism |
repository | https://github.com/mohnishsalian0/qrism |
max_upload_size | |
id | 1854993 |
size | 320,540 |
A Rust library for generating and reading QR codes with Reed-Solomon error correction. Supports traditional monochromatic QR codes with additional experimental multicolor QR support for 3x enhanced storage capacity.
Add this to your Cargo.toml
:
[dependencies]
qrism = "0.1.0"
use qrism::QRBuilder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Simplest usage - provide only data, all other settings are automatically chosen
let qr = QRBuilder::new(b"Hello, World!")
.build()?;
let img = qr.to_image(4); // 4x scale factor
img.save("simple_qr.png")?;
Ok(())
}
use qrism::reader::detect_qr;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load and prepare image
let img = image::open("qr_code.png")?;
// Detect and decode QR codes
let mut res = detect_qr(&img);
if let Some(symbol) = res.symbols().first_mut() {
let (metadata, message) = symbol.decode()?;
println!("Decoded: {}", message);
}
Ok(())
}
High capacity QR codes achieve 3x the storage capacity by leveraging color channels for data encoding. Unlike standard monochromatic QR codes that use only black and white modules, high capacity QR codes utilize the full RGB color spectrum by multiplexing three separate QR codes into a single visual code.
use qrism::QRBuilder;
use qrism::reader::detect_hc_qr;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a high capacity QR code with 3x storage
let large_data = "Large dataset that would not fit in a standard QR code...".repeat(10);
let qr = QRBuilder::new(large_data.as_bytes())
.high_capacity(true) // Enable high capacity mode
.build()?;
let img = qr.to_image(4);
img.save("high_capacity_qr.png")?;
// Reading high capacity QR codes
let img = image::open("high_capacity_qr.png")?;
let mut res = detect_hc_qr(&img);
if let Some(symbol) = res.symbols().first_mut() {
let (metadata, message) = symbol.decode()?;
println!("Decoded: {}", message);
}
Ok(())
}
See the examples/
directory for more comprehensive usage examples.
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Test images used from the ZXing project (https://github.com/zxing/zxing), licensed under the Apache License 2.0. Attribution is provided in accordance with the license.