-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
png file looks fine in browser, Pillow won't open it #6843
Comments
Hi. If I use
So the image is broken, and that is why it is failing to load in Pillow. However, if you would like to workaround this check, you can use from io import BytesIO
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
path = 'fig001.png'
with open(path, 'rb') as fp:
image_data = fp.read()
bio = BytesIO(image_data)
unsized_image = Image.open(bio) |
@eshellman did that answer your question? |
Yes, that solves my problem. Thank you! Two suggestions:
|
I've created PR #6856 to update the documentation as per your first suggestion. As for the second suggestion, a truncated image is an image that is truncated, e,g, #3023. For PNGs, the definition of this is broadened to include images that have missing chunk data or invalid chunk checksums. I don't know why anyone would think this constitutes a security problem? LENIENT and STRICT might better communicate what is happening in the case of PNGs, but as Pillow values backwards compatibility so I wouldn't want to remove |
Thanks, that makes sense. |
This is a rare problem, affecting 20 files of 1.04 million png files in Project Gutenberg!
What did you do?
What did you expect to happen?
Image created
What actually happened?
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: