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

Pillow 6.2 fails to open JPEG image with corrupted Photoshop metadata #4236

Closed
bstallenberger opened this issue Nov 27, 2019 · 3 comments · Fixed by #4239
Closed

Pillow 6.2 fails to open JPEG image with corrupted Photoshop metadata #4236

bstallenberger opened this issue Nov 27, 2019 · 3 comments · Fixed by #4239

Comments

@bstallenberger
Copy link

bstallenberger commented Nov 27, 2019

What did you do?

Tried to open a .jpg image with PIL.

What did you expect to happen?

The photo can be opened in a browser and by IrfanView (v4.53, 64bit, Windows 7).

What actually happened?

from PIL import Image
Image.open("test.jpg")
File "testFIL.py", line 3, in <module>
  im = Image.open("test.jpg")
File "/home/fe/stallenberger/anaconda3/envs/pillow/lib/python3.8/site-packages/PIL/Images.py", line 2818, in open
  raise IOError("cannot identify image file %r" % (filename if filename else fp))
OSError: cannot identify image file 'test.jpg'

What are your OS, Python and Pillow versions?

OS: Scientific Linux release 7.7 (Nitrogen)
Python: 3.8.0
Pillow: 6.2

Image file

test

For this particular image, the PhotoShop metadata (APP13 segment) seems to be corrupted since it ends with "8BIM". Normally, this tag introduces an Image Resource Block but in this particular file there is no data following in the APP13 segment. Thus, parsing this block of metadata and therefore opening the image fails.

Opening the image in Pillow 5.3.0 works well, since this version ignores the APP13 segment.

@radarhere radarhere changed the title Pillow 6.2 fails to open JPEG image with corrupted PhotoShop metadata Pillow 6.2 fails to open JPEG image with corrupted Photoshop metadata Nov 28, 2019
@radarhere
Copy link
Member

Thanks for reporting this. Is the image that you've supplied one that can be included in the test suite, and distributed under the Pillow license?

@radarhere
Copy link
Member

I've created PR #4239 to resolve this.

@bstallenberger
Copy link
Author

The image is from the Open Images dataset (V2, 2017-07) and can be retrieved from https://c2.staticflickr.com/3/2332/2154341610_9734c06295_o.jpg. Thus, the image should be under CC BY 2.0 license (see https://github.com/openimages/dataset/blob/master/READMEV2.md).

It should be OK to include the image in the test suite as long as a reference to the original source is included as well, but I'm not sure about this.

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 a pull request may close this issue.

2 participants