Pillow: Error opening png file

Created on 7 Jan 2019  路  10Comments  路  Source: python-pillow/Pillow

What did you do?

I tried to open image

What did you expect to happen?

Image to be opened without errors

What actually happened?

Pillow raised error.
Traceback:

File "/usr/local/lib/python3.6/dist-packages/PIL/Image.py", line 915, in convert
    self.load()
  File "/usr/local/lib/python3.6/dist-packages/PIL/ImageFile.py", line 252, in load
    self.load_end()
  File "/usr/local/lib/python3.6/dist-packages/PIL/PngImagePlugin.py", line 680, in load_end
    self.png.call(cid, pos, length)
  File "/usr/local/lib/python3.6/dist-packages/PIL/PngImagePlugin.py", line 140, in call
    return getattr(self, "chunk_" + cid.decode('ascii'))(pos, length)
AttributeError: 'PngStream' object has no attribute 'chunk_eXIf

What are your OS, Python and Pillow versions?

  • OS: Ubuntu 18.04.1 LTS x86_64
  • Python: 3.6
  • Pillow: 5.4.1

Demonstration code

from PIL import Image


img = Image.open('50767927-ad61c580-128f-11e9-879e-502cf52fc129.png')
img.load()

Image causing troubles

edit: Pillow version I use is 5.4.1, not 3.4.1

Most helpful comment

@nubonics @manashmndl Pillow 6.0.0 has now been released with this fix, so you should now be able to once again use the latest version of Pillow.

All 10 comments

With:

  • macOS High Sierra
  • Python 3.7.2

Cannot reproduce with:

  • Pillow 3.4.1
  • Pillow 5.3.0

Can reproduce with:

  • Pillow 5.4.0
  • Pillow 5.4.1 (latest)

Git bisect points to 22837c37e279a5fb3fb7b482d81e2c4d44c8cdcc from https://github.com/python-pillow/Pillow/pull/3506:

22837c37e279a5fb3fb7b482d81e2c4d44c8cdcc is the first bad commit
commit 22837c37e279a5fb3fb7b482d81e2c4d44c8cdcc
Date:   Mon Dec 24 23:58:19 2018 +1100

    Read textual chunks located after IDAT chunks

:040000 040000 bbc4e38e995ac826609218792b542d89d25ea138 efdb2cef1a1a438728c23dd94d162d23a8579df7 M  Tests
:040000 040000 5f47d2133fdfa73a7753f08203eb79d1d820a4e4 e38923295adea6da49623e6775bc95dfe483952c M  src

eXIf chunks are defined in 'Extensions to the PNG 1.2 Specification, Version 1.5.0'. This chunk was added to the spec on 15 July 2017.

I have created PR #3558 to resolve this.

This worked for me
conda install -c conda-forge -c pytorch -c fastai fastai=1.0.42
pip install pillow==5.3.0
pip install nvidia-ml-py3
If this doesn't work for you, feel free to write me, and I should respond within a day or less.

@nubonics on the 1st of April, the fix for this issue will be released as part of Pillow 6.0, and you should no longer need to pin Pillow to a lower version.

@Fogapod is the image that you provided able to be added to the test suite under Pillow's license? I'm interested for the sake of #3644

@radarhere yes. I just contacted author of this image, no problems with including it.

Thanks

This worked for me
conda install -c conda-forge -c pytorch -c fastai fastai=1.0.42
pip install pillow==5.3.0
pip install nvidia-ml-py3
If this doesn't work for you, feel free to write me, and I should respond within a day or less.

Thanks it's working!

@nubonics @manashmndl Pillow 6.0.0 has now been released with this fix, so you should now be able to once again use the latest version of Pillow.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boskicthebrain picture boskicthebrain  路  4Comments

steph-ben picture steph-ben  路  4Comments

naaaargle picture naaaargle  路  3Comments

Larivact picture Larivact  路  4Comments

mmalenta picture mmalenta  路  3Comments