#qr #codes #structured #codec #image-generation #data #append

qr_code

QR code encoder in Rust, support structured append (data in multiple qrcodes)

14 releases (3 stable)

2.0.0 May 30, 2023
1.1.0 Nov 21, 2020
0.19.0 Oct 22, 2020

#155 in Images

Download history 905/week @ 2024-07-28 424/week @ 2024-08-04 354/week @ 2024-08-11 304/week @ 2024-08-18 572/week @ 2024-08-25 874/week @ 2024-09-01 595/week @ 2024-09-08 584/week @ 2024-09-15 443/week @ 2024-09-22 568/week @ 2024-09-29 409/week @ 2024-10-06 627/week @ 2024-10-13 538/week @ 2024-10-20 399/week @ 2024-10-27 321/week @ 2024-11-03 418/week @ 2024-11-10

1,685 downloads per month
Used in 23 crates (10 directly)

MIT/Apache

310KB
7.5K SLoC

qr_code

crates.io MIT OR Apache 2.0

QR code encoder and decoder [*] in Rust. Documentation.

Encoder

This lib forked https://docs.rs/qrcode mainly because of lack of support to structured QR code (multiple QR codes) even if the minimal change required has been pushed https://github.com/kennytm/qrcode-rust/pull/44

Moreover dependencies image, checked_int_cast and module render has been removed with a view to simplicity.

Decoder [*]

Decoder part is based on https://docs.rs/rqrr/0.3.0/rqrr/ without the image detection part and is not intended for scanning QR codes from camera.

Decoder is included only for testing purpose, so that depending libraries could run round trip during tests.

Example

Bmp image generation

requires bmp feature

let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
let bmp = qr_code.to_bmp();
bmp.write(std::fs::File::create("test.bmp").unwrap()).unwrap();

Generate this image:

test

Looks small?

Many context supports rescaling mode specific for pixelated images, for example in html image-rendering: pixelated;

As an alternative see method Bmp::mul and Bmp::add_whitespace

Unicode string generation

let qr_code = qr_code::QrCode::new(b"Hello").unwrap();
println!("{}", qr_code.to_string(false, 3));

Generates this output (looks better in terminal):

                           
                           
   █▀▀▀▀▀█  ▀▀▀█ █▀▀▀▀▀█   
   █ ███ █ █ █ ▀ █ ███ █   
   █ ▀▀▀ █ ██ ▄▀ █ ▀▀▀ █   
   ▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀   
   ▀ ▀█▀▀▀ ▄▀ █▄▄█▀▀██ ▄   
     █▀▀█▀▄▄▀█▄█▄█▀ ██▀    
    ▀▀▀  ▀▀█▀▀ █  █ ▄  ▀   
   █▀▀▀▀▀█ ▄▀▄▀ ▀ ▄█▄██    
   █ ███ █ █▄ █▄█▄▄▀▄ ▀    
   █ ▀▀▀ █ ▀█ ▄█▄█▀▄▄█     
   ▀▀▀▀▀▀▀ ▀▀  ▀   ▀  ▀    
                           

Minimum Supported Rust Version (MSRV)

Current MSRV is 1.48.0

Dependencies

~0–280KB