zpao / qrcode.react

A <QRCode/> component for use with React.
https://zpao.github.io/qrcode.react/
Other
3.81k stars 327 forks source link

QR code not working when excavate = true #162

Closed mattx95 closed 3 years ago

mattx95 commented 3 years ago

I noticed that the QR code stops working (my phone no longer recognizes it) when the excavate property is True. Setting it to False fixes the issue, but looks a little worse (I'm adding an image to the QR code center, so without excavate there's no padding).

OMMatte commented 3 years ago

Yeah it makes no sense to have an image when the image simply removes parts of the QR code. Have it been working before?

zpao commented 3 years ago

Yea the allowable space estimate is a really rough approximation of what the error correction can compensate for. I've hit this too. That's why I ended up with this comment: https://github.com/zpao/qrcode.react/blob/cadda9de2a1cb838ea36264e4b4c14a91b059489/src/index.js#L97-L100

I decided it was too complex to actually calculate the allowable area that could be covered so it's ultimately up to users to determine the right sizes and image to use. I strongly recommend specifying and adjusting the dimensions you pass for the image, and potentially even bumping up the error correction level, which will result in better ability for readers to still decode.