Skip to content

How to use transparent background? #139

@tworun

Description

@tworun

Hello,
I am generating a QR code using this library and registering this QR code in a folder.
The background of this QR code is constantly white and I have to open it manually later using software such as CorelDraw - Illustrator and delete it.
Is there a way to automatically produce this without a white background, ie transparent?

My codes;

    use BaconQrCode\Renderer\Image\Svg;
    use BaconQrCode\Writer;
    use BaconQrCode\Renderer\Color\Cmyk;

    function utf8Encode($string) {
        return iconv(mb_detect_encoding($string, mb_detect_order(), true), 'UTF-8', $string);
    }

    $qrCodeContent = utf8Encode("BEGIN:VCARD\nVERSION:3.0\nN:". $name ." ". $surname ."\nEMAIL:$email\nTEL;TYPE=CELL:$gsmno\nTEL;TYPE=WORK:$is_telefonu\nURL:$website\nADR:". $ofisadres ."\nEND:VCARD");

    $renderer = new Svg();
    $renderer->setForegroundColor(new Cmyk(0, 0, 0, 100));

    $writer = new Writer($renderer);
    $qrCodeSvg = $writer->writeString($qrCodeContent);

    $filename = ''. $username .'.svg';

    $path = 'qr/' . $filename;

    file_put_contents($path, $qrCodeSvg);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions