Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR code image coule not be decode #13

Open
mengyyy opened this issue Aug 9, 2017 · 4 comments
Open

QR code image coule not be decode #13

mengyyy opened this issue Aug 9, 2017 · 4 comments

Comments

@mengyyy
Copy link

mengyyy commented Aug 9, 2017

System:
Ubuntu 16.04.3 LTS
Python:
Python 3.5.2
zbarlight==1.2
Pillow==4.2.1
lib:
libzbar-dev/xenial,now 0.10+doc-10ubuntu1 amd64 [installed]
libzbar0/xenial,now 0.10+doc-10ubuntu1 amd64 [installed]

First:
I meet a strange image coule not be decoded.
But i use telegram to send this image ,and use my bot to get it .It convert to jpeg by the telegram client and it could be decode success.
So I try to convert the raw png to jpeg by image.convert('RGB'), but this jpeg image fail decode .

The raw png image file: (failed decode)
qr_code_for_mobile_english_wikipedia svg
Convert by telegram Android client jpg file:(success decode)
photo_2017-08-09_14-25-22

Second:
I also found a image decode failed without any process, but after i use image.thumbnail() it could be decode success.
qrcode

Part of my code:

remote_image = requests.get(url)
image_file = io.BytesIO(remote_image.content)
image = Image.open(image_file)
image.load()
zbarlight.scan_codes('qrcode', image)
image.thumbnail((int(image.size[0]/8), int(image.size[1]/8)))
zbarlight.scan_codes('qrcode', image)
@fbochu
Copy link
Contributor

fbochu commented Aug 16, 2017

Hi, thanks for the report.

I reproduce the issue with the two files. I have create PR #14 to investigate the issues.

For the first file, I believe that the problem is due to the gray scale conversion which in this case set the background to black (setting the background color to white resolve the issue, see the test_need_conversion_to_jpg_sample test). For the second one, I do not have any idea.

@mengyyy
Copy link
Author

mengyyy commented Aug 18, 2017

Thank you solve the first one.
For the second one,i found whne its sise >(600,600) decode fail, but when its size turn to (599,599) or less, decode success.

@fbochu
Copy link
Contributor

fbochu commented Aug 23, 2017

When adding a black border of 5px around the QR Code, the code is correctly decoded. But when adding a white border even a 1000px one, the code can not be read... This is surprising !

It's seem to be a bug or misusage of the Zbar library, but I have not find anything relative to this issue in the documentation or in the bug tracker. Unfortunately it's seem that there are not activity on the Zbar library since October 2012 (5 years ago).

This bug is beyond my expertise, I sorry that I can not help you more.

@AndreMiras
Copy link

AndreMiras commented Feb 23, 2019

What about the forks?
That one seems maintained for instance https://github.com/mchehab/zbar
Edit 1: to give more context I saw it here ZBar/ZBar#17
Edit 2: I saw that you guys started taking a look, that's awesome 9496c4e keep up the good work 🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants