six-two / qr.html

A standalone offline HTML5 QR code generator
https://qr.15c.me
The Unlicense
108 stars 34 forks source link

Suggestion: add option for border in the generated image. #2

Closed GAZ082 closed 1 year ago

GAZ082 commented 1 year ago

Hey there.

The Google Assistant QR engine does not work if the background where the QR is on is black (ie, when opening the image saved in the Photo gallery). This is solved if instead of saving the image i take a screenshot and give some bezel to it by copying some of the grey background.

Can you add a couple of constants in the code to allow me:

  1. Define the bezel size within the generated QR in the canvas.
  2. Define the color of it.

Thanks!

six-two commented 1 year ago

Hi Gabriel,

I implemented it in commit d893684. It was a bit harder than I thought, since the QR engine does not offer a direct option for this. So my approach was to scale the image afterwards, which makes it perform rather slugishly while resizing the window. But it should work for now and if I find some time in the future, I may improve it.

The new options QR_BORDER_SIZE and QR_BORDER_COLOR in qr.html do pretty much what you asked for and should be self-explanatory. 😄

BR, six-two

GAZ082 commented 1 year ago

Now works fine as a local image in any Android phone with Google Assistant! Thanks a lot!