alexeyten / qr-image

Yet another QR code generator
MIT License
1.05k stars 168 forks source link

Support JPEG image format #55

Closed jschulenklopper closed 5 years ago

jschulenklopper commented 5 years ago

Currently, only (lossless) PNG, SVG, EPS and PDF formats are supported, but (lossy) JPEG is also a common format for images. It could be a valuable addition to support.

bockoblur commented 5 years ago

If you're in browser environment, you can use HTML5 canvas element for that. Just draw the image in a canvas. (Make the canvas element hidden if you want). Then use canvas.toDataURL("image/jpeg"); to get the Base64 of JPEG. If you're in nodejs environment, you can use various npm packages (i.e. jimp) to convert buffer with PNG data to JPEG.

jschulenklopper commented 5 years ago

Sure. But it could also be supported directly, without needing to use other libraries or tools. The PDF could also have been simulated using separate printing tools or libs... but still exists as output format.

(Using the libary from Node.js, server-side.)

alexeyten commented 5 years ago

All supported formats are simple text, including PDF.

PNG is exception, but I had reasons to implement it. Also my implementation is as simple as it possible, and I had good knowledge of format.

I know nothing about JPEG, so I would advise to simply generate png and use some other tool to covert it to jpeg.

jschulenklopper commented 5 years ago

Oh, my problem is solved - by using another QR code library to generate JPG, PNG or SVG image formats.

I just thought it would be a valuable addition to this one - also since that’s the reason I moved away - so I registered the ticket.

There’s no expectation or demand that you implement this, esp. if it’s not in the product vision, roadmap or project member capabilities. It is just a suggestion for the project’s consideration.

Feel free to close this ticket.