nuintun / qrcode

A pure JavaScript QRCode encode and decode library.
https://nuintun.github.io/qrcode
MIT License
194 stars 26 forks source link

Provide scalable image format #319

Closed FantasqueX closed 11 months ago

FantasqueX commented 1 year ago

Hi, I have a question about how to fit the generated qrcode into my HTML. Currently, the generated qrcode is a GIF image which is not scalable. And I don't know how to set moduleSize to fit the desired size. So, could you please provide an option to export SVG or to draw a Canvas automatically?

nuintun commented 11 months ago

Use toDataURL(moduleSize?: number, margin?: number): string scale image.

Image size = (version 4 + 17) moduleSize + margin * 2

Also you can use getMatrix get qrcode matrix and draw svg or canvas by youself!