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

Added IGNORE_DECODING_ERRORS flag to ImageFile allowing corrupted images to load #311

Merged
merged 1 commit into from
Jul 30, 2013

Conversation

cezarsa
Copy link
Contributor

@cezarsa cezarsa commented Jul 30, 2013

Since commit 33bf5d9 PIL is no longer able to load this image even after setting ImageFile.LOAD_TRUNCATED_IMAGES = True because of the t == 0 check that was introduced then.

Because I'm not sure about what use cases @d-schmidt had in mind when the size check was added, I've introduced a new flag called IGNORE_DECODING_ERRORS that if True will never raise IOError. This should make everyone happy.

aclark4life added a commit that referenced this pull request Jul 30, 2013
Added IGNORE_DECODING_ERRORS flag to ImageFile allowing corrupted images to load
@aclark4life aclark4life merged commit ba82e34 into python-pillow:master Jul 30, 2013
@aclark4life
Copy link
Member

Thanks

@d-schmidt
Copy link
Contributor

A broken image? Great :) Will check this out tomorrow.

@d-schmidt
Copy link
Contributor

I didn't know t can be zero if image data is loaded. I just assumed, without proof, that t is only 0 if there is no image data at all.

@cezarsa
Copy link
Contributor Author

cezarsa commented Jul 30, 2013

You have to set it manually after importing ImageFile.

from PIL import ImageFile
ImageFile.IGNORE_DECODING_ERRORS = True

Maybe this extra flag is unnecessary and we could just change the behavior of LOAD_TRUNCATED_IMAGES. I'll look for more partially corrupted jpeg images and write a test case using them. It should make it easier to figure out if we need both.

@aclark4life
Copy link
Member

Got it, thanks

@d-schmidt
Copy link
Contributor

Imho revert this.
The file opens just fine with only my old flag set true. Using current pillow and jpeglib8. Don't know whats your problem @cezarsa. t is 65406 the moment it breaks truncated.
Please test it again with just

ImageFile.LOAD_TRUNCATED_IMAGES = True

@wiredfool
Copy link
Member

Works for me (ubuntu 12.04/py2,3) with @d-schmidt 's old flag. +1 revert

@aclark4life
Copy link
Member

Yep, already reverted

@homm homm mentioned this pull request Sep 15, 2015
radarhere pushed a commit to radarhere/Pillow that referenced this pull request Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants