erwanvivien / fast_qr

Ultra fast QRCode generation
https://fast-qr.com/
MIT License
197 stars 29 forks source link

Bug: Duplicate Rectangles in SVG Output #61

Closed TheAwiteb closed 1 month ago

TheAwiteb commented 1 month ago

Hi, thank you for this amazing library. I'm facing a bug where two rectangles are appearing in the resulting SVG instead of just one. The first rectangle takes the QR code background color, while the second one takes the image background color. I believe the first rectangle at this line should be removed.

My code is

use fast_qr::{
    convert::{svg::SvgBuilder, Builder, Color},
    QRBuilder, Version, ECL,
};

const RUSTACEAN_LOGO: &str = "data:image/svg+xml;base64,BASE_64_IMAGE";

fn main() {
    let qrcode = QRBuilder::new("https://rust-lang.org")
        .ecl(ECL::Q)
        .version(Version::V03)
        .build()
        .unwrap();

    let _svg = SvgBuilder::default()
        .image(RUSTACEAN_LOGO.to_string())
        .image_background_color(Color::from([0, 0, 0, 0])) // <-- The image background is transparent
        .to_file(&qrcode, "svg.svg");
}
Code Result Should be
TheAwiteb commented 1 month ago

I can open PR remove this rectangle, if i'am correct

erwanvivien commented 1 month ago

Thanks for the kind words and the detailed issue as well as the PR 💜