Skip to content

Image.verify fails to detect corrupted file #6342

Description

@LilithHafner

I have a .png file that passes verify() but fails on load() I expect the error has to do with compression within the IDAT chunk.

>>> from PIL import Image
>>> img = Image.open("test image (800x600).png")
>>> img.verify()
>>> img = Image.open("test image (800x600).png")
>>> img.load()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/ImageFile.py", line 274, in load
    raise_oserror(err_code)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/ImageFile.py", line 67, in raise_oserror
    raise OSError(message + " when reading image file")
OSError: broken data stream when reading image file

Test image:
test image (800x600)

Versions:

  • OS: macOS 12.2.1
  • Python: Python 3.9.5
  • Pillow: 8.3.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions