EasyQRCodeJS icon indicating copy to clipboard operation
EasyQRCodeJS copied to clipboard

svg logo in svg download

Open Gabilabrebi opened this issue 2 years ago • 4 comments

Hello

When we use a svg logo, the svg QR Code download should include this vectorial logo.

It makes sense (imo) to remove it if it's an image and we download the QR Code as svg, but why remove it if this is all vectorial?

Would be great if it could be implemented :)

Regards

Gabilabrebi avatar Feb 16 '24 10:02 Gabilabrebi

Hi, unless you use images in base64 format, any external images will be subject to browser download restrictions.

https://github.com/ushelp/EasyQRCodeJS?tab=readme-ov-file#download-the-qrcode-image-in-the-browser

ushelp avatar Mar 22 '25 09:03 ushelp

Hello. Thanks you for your answer

I understand the limitation, but it's sort of an edge case. Most of the time, when talking about svg it will be internal svg or external svg but where you can still read the svg string, and it could be possible to generate a full svg. Fallback to image download if it's not possible is of course acceptable but i think it should be fallback, not general rule because this edge case exists.

Gabilabrebi avatar Mar 22 '25 10:03 Gabilabrebi

Hi @Gabilabrebi , Can you share your example so that I can better evaluate the feasibility of your idea?

ushelp avatar Mar 24 '25 11:03 ushelp

Hello @ushelp

My example is simple. 100% front. I have an url and generate QR code form it. People can then personalize the QR code (colors etc), and can also embed there logo at in the QRcode if they want. This is done trough an input file <input id="qrlogo" type="file" accept=".jpg,.png,.jpeg,.gif,.webp,.avif,.tiff,.svg">. As you can see, this input accept both images and svgs.

Every time time they change personalization, I regenerate the logo to display a preview.

After personalization, they can download there QR code. At that moment, if there is no logo, they can chose between svg and img for the download. However, if they add a logo (even if it's an svg logo), only image download is possible. At that point, the svg is inside the input file, so you have access to the data it contains. People would appreciate downloading an svg QR code with there svg logo inside. This would help for printing etc, but you already know this :)

Let me know if you need more details.

Gabilabrebi avatar Mar 24 '25 13:03 Gabilabrebi