qreader icon indicating copy to clipboard operation
qreader copied to clipboard

Unable to read simple QR codes

Open anuraguniyal opened this issue 8 years ago • 3 comments

I tried it on a several QR code and it failed.

$ python -c "import qreader; qreader.read('qr.png')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "qreader/api.py", line 26, in read
    return QRDecoder(data).get_first()
  File "qreader/decoder.py", line 21, in get_first
    return self._decode_next_message()
  File "qreader/decoder.py", line 30, in _decode_next_message
    mode = self.scanner.read_int(4)
  File "qreader/scanner.py", line 60, in read_int
    self.read()
  File "qreader/scanner.py", line 33, in read
    self.read_info()
  File "qreader/scanner.py", line 89, in read_info
    info.block_size = self.get_block_size(info.canvas[:2])
  File "qreader/scanner.py", line 133, in get_block_size
    if self._get_pixel((left + i * pattern_size, top)) == WHITE:
  File "qreader/scanner.py", line 98, in _get_pixel
    return 1 if self.image.getpixel(coords) < 128 else 0
  File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1215, in getpixel
    return self.im.getpixel(xy)
IndexError: image index out of range

It was generated from http://bitcoinqrcode.org/ also attached here qr

anuraguniyal avatar Feb 24 '17 17:02 anuraguniyal

Hi there, Sorry for not getting to this earlier. There seem to have been a problem with the transparent border of the image (the area around the QR code is not white but transparent-black).

I solved the bug, but can I add a test using this QR code image, or is it sensitive? (just making sure)

ewino avatar Nov 29 '17 21:11 ewino

Thanks for fixing this. Yes please go ahead with same image or generate new one at http://www.bitcoinqrcode.org/

anuraguniyal avatar Nov 29 '17 21:11 anuraguniyal

Great. There still seems to be issues with decoding it, so I'm not marking it as closed yet, but at least it doesn't crash. I'll keep this updated :)

ewino avatar Nov 29 '17 22:11 ewino