use qr_code_styling::config::{Color, DotsOptions, ImageOptions};
use qr_code_styling::types::{DotType, OutputFormat};
use qr_code_styling::QRCodeStyling;
use std::path::PathBuf;
fn main() -> qr_code_styling::error::Result<()> {
let manifest_dir = env!("CARGO_MANIFEST_DIR");
let logo_path = PathBuf::from(manifest_dir).join("examples/logo.png");
println!("Loading logo from: {}", logo_path.display());
let logo_bytes = std::fs::read(&logo_path)?;
println!("Logo size: {} bytes", logo_bytes.len());
std::fs::create_dir_all("output")?;
println!("\nGenerating QR code with centered logo...");
let qr = QRCodeStyling::builder()
.data("https://rust-lang.org")
.size(400)
.image(logo_bytes)
.image_options(
ImageOptions::default()
.with_image_size(0.4) .with_margin(5) .with_hide_background_dots(true), )
.dots_options(DotsOptions::new(DotType::Rounded).with_color(Color::from_hex("#2C3E50").unwrap()))
.build()?;
qr.save("output/with_logo.svg", OutputFormat::Svg)?;
println!("Saved: output/with_logo.svg");
qr.save("output/with_logo.png", OutputFormat::Png)?;
println!("Saved: output/with_logo.png");
println!("\nDone!");
Ok(())
}