Pillow: AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'

Created on 1 Apr 2020  路  17Comments  路  Source: python-pillow/Pillow

What did you do?

My library BentoML is using imageio and Pillow in its tests, and with the latest release of Pillow 7.1.0 half an hour ago, I noticed some existing tests are breaking.

https://github.com/bentoml/BentoML
https://travis-ci.org/github/bentoml/BentoML/jobs/669765333?utm_medium=notification&utm_source=github_status

What did you expect to happen?

imageio.imread('./image.png') should work

What actually happened?

AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'

Screen Shot 2020-04-01 at 9 26 25 AM

What are your OS, Python and Pillow versions?

  • OS: mac os
  • Python: 3.75
  • Pillow: 7.1.0
  • imageio: 2.8.0
from imageio import imread
imread('./test.png')

It seems related to https://github.com/python-pillow/Pillow/pull/4243

Bug

Most helpful comment

I can confirm for napari that all tests fails and issues we observed in 7.1.0 and 7.1.1 are fixed in 7.2.0.dev0. thanks!

All 17 comments

Git bisect says 67e3ccffeb09903e22c29d737e74070415890ed8 is the first bad commit, from #4243.

commit 67e3ccffeb09903e22c29d737e74070415890ed8
Date:   Sun Dec 1 12:50:21 2019 +0900

    Add APNG support

    See #3483

    Adds support for reading APNG files and seeking through frames,
    and adds basic support for writing APNG files.

 src/PIL/PngImagePlugin.py | 401 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 390 insertions(+), 11 deletions(-)

@pmrowla Hi, please could you check this? Thank you!

Ping @almarklein from https://github.com/imageio/imageio, FYI.

Minimal test case, not using imageio:

from PIL import Image

im = Image.open("Tests/images/hopper.png")
im.seek(0)

Possible fix:

diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py
index 5bb0e2ff..afa39bc9 100644
--- a/src/PIL/PngImagePlugin.py
+++ b/src/PIL/PngImagePlugin.py
@@ -631,6 +631,7 @@ class PngImageFile(ImageFile.ImageFile):

     format = "PNG"
     format_description = "Portable network graphics"
+    __frame = 0

     def _open(self):

we're seeing this too in our tests at napari.

@hugovk's change in #4512 fixes this for me. Sorry for the hassle everyone!

I'm seeing this too. I believe it's caused by PIL 7.1.0. 7.0.0 works fine.

@pmrowla Thanks for checking! I've merged #4512.

Others: if you could test with master for any other regressions, that'd be appreciated.

Pillow 7.1.1 has been released with a fix for this: https://github.com/python-pillow/Pillow/issues/4354#issuecomment-608020894.

Thanks all!

Thanks for the very quick fix! just curious whether think you might end up removing 7.1.0 from pypi? (or whether we should keep Pillow!=7.1.0 in our requirements.txt even if pillow is just an indirect dependency)

For an indirect dependency, you're probably fine removing it, especially as there was only a short time between 7.1.0 and 7.1.1.

If the problem comes up (seldom), you could ask people to upgrade. If it comes up a lot, you could pin it, or alternatively ask the dependency to add !=7.1.0.

can do. thanks!

Moved to #4518

@nabobalis I'd guess this is also a Pillow bug, there were big changes to PngImagePlugin.py in 7.1. Please could you report a new issue? https://github.com/python-pillow/Pillow/issues/new?template=ISSUE_REPORT.md

@pmrowla Please could you have a look at this?

See also https://github.com/google/fonts/pull/2380#issuecomment-608058926.

Thanks!

We've merged a fix (https://github.com/python-pillow/Pillow/pull/4528) for the new bug (https://github.com/python-pillow/Pillow/issues/4518). Before we release, it would be helpful if people could run their test suites with the master branch to check if there are other regressions. Thanks!

I can confirm for napari that all tests fails and issues we observed in 7.1.0 and 7.1.1 are fixed in 7.2.0.dev0. thanks!

Pillow 7.1.2 has now been released with the fix for the second problem described here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steph-ben picture steph-ben  路  4Comments

anonymous530 picture anonymous530  路  3Comments

boskicthebrain picture boskicthebrain  路  4Comments

Larivact picture Larivact  路  4Comments

damianmoore picture damianmoore  路  4Comments