Skip to content

Malformed APP1 EXIF segment are not ignored #7456

@deepio

Description

@deepio

What did you do?

Tried to open an image from a Samsung device with malformed exif data. I can't control how the device will take pictures. I can open the image successfully in Paintbrush and other image manipulation tools, but not in Apple preview.

What did you expect to happen?

To ignore the segment and let me work with them pixels please.

What actually happened?

Traceback (most recent call last):
  File "/Users/deepio/Desktop/ape.py", line 7, in <module>
    image = Image.open(file)
  File "/Users/deepio/.pyenv/versions/3.10.4/lib/python3.10/site-packages/PIL/Image.py", line 3280, in open
    raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file 'bad_file.jpg'

What are your OS, Python and Pillow versions?

  • OS: ubuntu 22.04 and MacOS
  • Python: 3.10.4, 3.9, ...
  • Pillow: 10.0.1
from PIL import Image
file = "bad_file.jpg"

image = Image.open(file)

I tested to make sure that the scrubbed image still created the same issue and it does (bad_file2.jpg). I zipped the image just in-case github does some image manipulation on uploaded files, bad_file2.jpg is the same image with all white pixels and with the weird APP1 segment added.

bad_file2.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions