Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #7456

The image in the issue raises a UnidentifiedImageError. Hiding behind that is the following traceback when attempting to read DPI from JPEG EXIF.

Traceback (most recent call last):
  File "PIL/ImageFile.py", line 117, in __init__
  File "PIL/JpegImagePlugin.py", line 382, in _open
  File "PIL/JpegImagePlugin.py", line 160, in APP
  File "PIL/Image.py", line 1441, in getexif
  File "PIL/Image.py", line 3730, in load
  File "PIL/TiffImagePlugin.py", line 526, in __init__
  File "PIL/TiffImagePlugin.py", line 670, in _unpack
struct.error: unpack requires a buffer of 4 bytes

This PR adds struct.error to the list of exceptions caught, to handle this truncated data. The test image comes from the issue.

@hugovk hugovk merged commit ff37a5b into python-pillow:main Oct 13, 2023
@radarhere radarhere deleted the truncated_exif branch October 13, 2023 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed APP1 EXIF segment are not ignored

2 participants