#[path = "support.rs"]
mod support;
use qrc::QRCode;
fn main() {
support::header("qrc -- resize");
let qr = QRCode::from_string("https://example.com".to_string());
support::task_with_output("Thumbnail for app icons (64x64)", || {
let img = qr.resize(64, 64);
let (w, h) = img.dimensions();
vec![
format!("Dimensions: {}x{} px", w, h),
format!("Pixels: {}", w as usize * h as usize),
format!("Use case: Favicon, notification badge"),
]
});
support::task_with_output("Social media post (512x512)", || {
let img = qr.resize(512, 512);
let (w, h) = img.dimensions();
vec![
format!("Dimensions: {}x{} px", w, h),
format!("Use case: Instagram story, Twitter post"),
]
});
support::task_with_output("Print-ready (1200x1200 for 300 DPI)", || {
let img = qr.resize(1200, 1200);
let (w, h) = img.dimensions();
vec![
format!("Dimensions: {}x{} px", w, h),
format!(
"At 300 DPI: {:.1}x{:.1} inches",
f64::from(w) / 300.0,
f64::from(h) / 300.0
),
format!("Use case: Flyers, posters, packaging"),
]
});
support::task_with_output("Banner aspect ratio (800x400)", || {
let img = qr.resize(800, 400);
let (w, h) = img.dimensions();
vec![
format!("Dimensions: {}x{} px", w, h),
format!("Ratio: {}:{}", w / 400, h / 400),
format!("Use case: Email banner, horizontal placement"),
]
});
support::task_with_output("Square resize via resize! macro (256x256)", || {
let img = qrc::resize!(qr, 256);
let (w, h) = img.dimensions();
vec![
format!("Dimensions: {}x{} px", w, h),
format!("Macro: resize!(qr, 256)"),
]
});
support::summary(5);
}