Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/houseme/qrcode-rs
QR code encoder in Rust,Generate QR Code matrices and images in RAW, PNG and SVG formats.
https://github.com/houseme/qrcode-rs
encoder encoder-decoder qrcode qrcode-generator rust rust-lang rust-library
Last synced: 9 days ago
JSON representation
QR code encoder in Rust,Generate QR Code matrices and images in RAW, PNG and SVG formats.
- Host: GitHub
- URL: https://github.com/houseme/qrcode-rs
- Owner: houseme
- License: apache-2.0
- Created: 2022-12-11T03:40:17.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-16T05:12:37.000Z (22 days ago)
- Last Synced: 2024-10-17T17:57:26.593Z (20 days ago)
- Topics: encoder, encoder-decoder, qrcode, qrcode-generator, rust, rust-lang, rust-library
- Language: Rust
- Homepage: https://houseme.github.io/qrcode-rs/
- Size: 104 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
Qrcode-rs
===========[![Build](https://github.com/houseme/qrcode-rs/workflows/Build/badge.svg)](https://github.com/houseme/qrcode-rs/actions?query=workflow%3ABuild)
[![crates.io](https://img.shields.io/crates/v/qrcode-rs.svg)](https://crates.io/crates/qrcode-rs)
[![docs.rs](https://docs.rs/qrcode-rs/badge.svg)](https://docs.rs/qrcode-rs/)
[![License](https://img.shields.io/crates/l/qrcode-rs)](./LICENSE-APACHE)
[![Crates.io](https://img.shields.io/crates/d/qrcode-rs)](https://crates.io/crates/qrcode-rs)QR code and Micro QR code encoder in Rust. [Documentation](https://docs.rs/qrcode-rs).
Cargo.toml
----------```toml
[dependencies]
qrcode-rs = "0.1"
```The default settings will depend on the `image` crate. If you don't need image generation capability, disable the `default-features`:
```toml
[dependencies]
qrcode-rs = { version = "0.1", default-features = false }
```Example
-------## Image generation
```rust
use qrcode_rs::QrCode;
use image::Luma;fn main() {
// Encode some data into bits.
let code = QrCode::new(b"01234567").unwrap();// Render the bits into an image.
let image = code.render::>().build();// Save the image.
image.save("/tmp/qrcode.png").unwrap();
}
```Generates this image:
![Output](docs/images/test_annex_i_qr_as_image.png)
## String generation
```rust
use qrcode_rs::QrCode;fn main() {
let code = QrCode::new(b"Hello").unwrap();
let string = code.render::()
.quiet_zone(false)
.module_dimensions(2, 1)
.build();
println!("{}", string);
}
```Generates this output:
```none
############## ######## ##############
## ## ## ## ##
## ###### ## ## ## ## ## ###### ##
## ###### ## ## ## ## ###### ##
## ###### ## #### ## ## ###### ##
## ## #### ## ## ##
############## ## ## ## ##############
## ##
## ########## ## ## ##########
## ## ######## #### ##
########## #### ## #### ######
## ## #### ########## ####
###### ########## ## ## ##
## ## ## ##
############## ## ## ## ## ####
## ## ## ## ##########
## ###### ## ## ## ## ## ##
## ###### ## #### ########## ##
## ###### ## #### ## #### ##
## ## ## ######## ######
############## #### ## ## ##
```## SVG generation
```rust
use qrcode_rs::{QrCode, Version, EcLevel};
use qrcode_rs::render::svg;fn main() {
let code = QrCode::with_version(b"01234567", Version::Micro(2), EcLevel::L).unwrap();
let image = code.render()
.min_dimensions(200, 200)
.dark_color(svg::Color("#800000"))
.light_color(svg::Color("#ffff80"))
.build();
println!("{}", image);
}
```Generates this SVG:
[![Output](docs/images/test_annex_i_micro_qr_as_svg.svg)](docs/images/test_annex_i_micro_qr_as_svg.svg)
## Unicode string generation
```rust
use qrcode_rs::QrCode;
use qrcode_rs::render::unicode;fn main() {
let code = QrCode::new("mow mow").unwrap();
let image = code.render::()
.dark_color(unicode::Dense1x2::Light)
.light_color(unicode::Dense1x2::Dark)
.build();
println!("{}", image);
}
```Generates this output:
```text
█████████████████████████████
█████████████████████████████
████ ▄▄▄▄▄ █ ▀▀▀▄█ ▄▄▄▄▄ ████
████ █ █ █▀ ▀ ▀█ █ █ ████
████ █▄▄▄█ ██▄ ▀█ █▄▄▄█ ████
████▄▄▄▄▄▄▄█ ▀▄▀ █▄▄▄▄▄▄▄████
████▄▀ ▄▀ ▄ █▄█ ▀ ▀█ █▄ ████
████▄██▄▄▀▄▄▀█▄ ██▀▀█▀▄▄▄████
█████▄▄▄█▄▄█ ▀▀▄█▀▀▀▄█▄▄████
████ ▄▄▄▄▄ █ ▄▄██▄ ▄ ▀▀████
████ █ █ █▀▄▄▀▄▄ ▄▄▄▄ ▄████
████ █▄▄▄█ █▄ █▄▀▄▀██▄█▀████
████▄▄▄▄▄▄▄█▄████▄█▄██▄██████
█████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
```## License
Licensed under either of* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
### Thanks to [Kennytm](https://github.com/kennytm), this package is based on [`qrcode-rust`](https://github.com/kennytm/qrcode-rust).