Contents
- Install — add it and start generating
- Quick Start — a QR code in 4 lines
- Overview — what QRC does
- Features — v0.0.6 capability matrix
- Library Usage — formats, styling, watermarks
- Structured Payloads — vCard, Wi-Fi, MeCard, EMVCo
- Macros — 11 convenience macros
- Examples — 20 focused examples
- Development — build, test, lint
- Security — safety guarantees
- Documentation
- License
Install
[]
= "0.0.6"
…or from the command line:
Cargo features
| Feature | Default | Pulls in | Adds |
|---|---|---|---|
| (core) | ✓ | image, qrcode, miniz_oxide |
QR generation, PNG/JPG/GIF/SVG, payloads, macros |
wasm |
wasm-bindgen, js-sys |
WebAssembly bindings (qrc::wasm) for the browser |
The core API needs no default features. The image dependency is compiled
with only the png, jpeg, gif, and ico codecs, keeping the tree lean.
Build from source
Requires Rust 1.75.0+ (MSRV). Tested on Linux, macOS, and Windows.
Quick Start
use QRCode;
Overview
QRC turns strings, byte vectors, or raw data into QR code images. It renders to
four formats, lets you pick the error-correction level and module shape, and
ships builders for structured payloads (contacts, Wi-Fi, payments) — all with
zero unsafe.
- 4 output formats — PNG, JPG, GIF, SVG
- Styling — 4 error-correction levels and 4 module shapes
- Structured payloads — vCard, Wi-Fi, MeCard, EMVCo merchant payments
- Colour customisation — any RGBA colour for dark modules
- Watermarks & overlays — corner watermark or centre logo
- Batch generation — many codes in one call
- Zero unsafe code —
#![forbid(unsafe_code)]crate-wide
Features
| Formats | PNG, JPG, GIF (raster via image), SVG (vector via qrcode) |
| Error correction | EcLevel::{L, M, Q, H} via with_ec_level (default M) |
| Module shapes | ModuleShape::{Square, RoundedSquare, Circle, Diamond} via with_shape |
| Payloads | payload::{vcard, wifi, mecard, emvco} — dependency-free string builders |
| Colours | Custom RGBA dark modules on a white background |
| Watermarks / Overlays | Alpha-blended corner watermark; centre logo overlay |
| Resizing | Arbitrary width/height scaling |
| Batch / Combine | Vec<String> → Vec<QRCode>; merge codes side-by-side |
| Macros | 11 convenience macros |
| Safety | #![forbid(unsafe_code)], #![deny(missing_docs)] |
| MSRV | Rust 1.75.0 |
| Runtime deps | 3 (image, qrcode, miniz_oxide) |
Library Usage
use QRCode;
use ;
use QRCode;
use Rgba;
use QRCode;
use ;
use QRCode;
Structured Payloads
qrc::payload builds the exact text conventions scanners act on — so a scan
offers "Add to Contacts" or "Join Wi-Fi" instead of showing raw text. The
builders are plain strings with no extra dependencies.
use QRCode;
use BusinessCard;
use ;
| Builder | Module | Emits |
|---|---|---|
BusinessCard |
payload::vcard |
RFC 6350 vCard 3.0 |
WifiNetwork |
payload::wifi |
WIFI: join string |
MeCard |
payload::mecard |
Compact contact |
MerchantPayment |
payload::emvco |
EMVCo MPM + CRC-16/CCITT |
Macros
11 convenience macros for common operations:
| Macro | Description |
|---|---|
qr_code!(data) |
Create a new QR code |
qr_code_to!(data, format, width) |
Create in a specific format (png/jpg/gif) |
add_image_watermark!(img, watermark) |
Add a watermark to a QR image |
resize!(qrcode, size) |
Resize to square dimensions |
set_encoding_format!(qr, format) |
Set the encoding format |
overlay_image!(qr, image) |
Overlay a logo at the centre |
batch_generate_qr!(data_list) |
Generate multiple QR codes |
compress_data_macro!(data) |
Compress data via Zlib |
combine_qr_codes!(codes) |
Combine codes side-by-side |
create_dynamic_qr!(data) |
Create a dynamic (URL-based) QR code |
create_multilanguage_qr!("en" => "Hello", ...) |
Multi-language QR code |
See the macros example for full usage.
Examples
| Example | Purpose |
|---|---|
basic |
Construction from bytes, strings, and vectors |
formats |
Export to PNG, JPG, GIF, and SVG |
colorize |
Custom RGBA module colours |
resize |
Print, web, and thumbnail sizing |
watermark |
Alpha-blended watermark logos |
overlay |
Centre-placed logo |
compress |
Zlib-compress data before encoding |
batch |
Generate many codes from a URL list |
combine |
Merge codes into one image |
encoding |
Set and validate encoding formats |
dynamic |
Updatable URL-based codes |
multilingual |
Language-aware codes from a translation map |
macros |
All 11 convenience macros |
vcard |
vCard contact card |
wifi |
Wi-Fi join code |
mecard |
Compact MeCard contact |
emvco |
EMVCo merchant payment |
business_card |
Branded vCard QR — centred logo + quiet zone, stays scannable |
control_image |
Export a ControlNet control image (for SD QR art) |
art_qr |
Offline image-blended "art QR" — no model needed |
Development
CI
| Workflow | Trigger | Purpose |
|---|---|---|
ci.yml |
push, PR | fmt, clippy, test (3 OS), MSRV, cargo-deny, security audit |
document.yml |
push to main |
Build and deploy API docs |
release.yml |
tag v* |
Cross-platform binaries, crates.io publish |
See CONTRIBUTING.md for PR guidelines.
Security
#![forbid(unsafe_code)]across the entire codebase#![deny(missing_docs)]— every public item is documentedcargo audit(RustSec) andcargo deny(licenses, advisories, bans) in CI- SPDX license headers on all source files
- 3 runtime dependencies — minimal attack surface
Documentation
Full API reference: docs.rs/qrc.
Changelog
See CHANGELOG.md for release notes, including the breaking changes in 0.0.6.
License
Dual-licensed under Apache 2.0 or MIT, at your option.
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.