Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
parano opened this issue Apr 1, 2020 · 17 comments · Fixed by #4512
Closed

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

parano opened this issue Apr 1, 2020 · 17 comments · Fixed by #4512
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@parano
Copy link

parano commented Apr 1, 2020

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 #4243

@hugovk
Copy link
Member

hugovk commented Apr 1, 2020

Git bisect says 67e3ccf 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!

@hugovk
Copy link
Member

hugovk commented Apr 1, 2020

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

@hugovk hugovk changed the title Issue reading PNG files ImageIO: AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame' Apr 1, 2020
@hugovk
Copy link
Member

hugovk commented Apr 1, 2020

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):

@hugovk hugovk added the Bug Any unexpected behavior, until confirmed feature. label Apr 1, 2020
@tlambert03
Copy link

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

@hugovk hugovk changed the title ImageIO: AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame' AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame' Apr 1, 2020
@hugovk
Copy link
Member

hugovk commented Apr 1, 2020

Possible fix: #4512.

@pmrowla
Copy link
Contributor

pmrowla commented Apr 2, 2020

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

@SteveDoyle2
Copy link

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

@hugovk
Copy link
Member

hugovk commented Apr 2, 2020

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

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

@hugovk
Copy link
Member

hugovk commented Apr 2, 2020

Pillow 7.1.1 has been released with a fix for this: #4354 (comment).

Thanks all!

@tlambert03
Copy link

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)

@hugovk
Copy link
Member

hugovk commented Apr 2, 2020

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.

@tlambert03
Copy link

can do. thanks!

@nabobalis
Copy link

nabobalis commented Apr 3, 2020

Moved to #4518

@hugovk
Copy link
Member

hugovk commented Apr 3, 2020

@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 google/fonts#2380 (comment).

Thanks!

m4rc1e added a commit to googlefonts/gftools that referenced this issue Apr 6, 2020
Versions greater than 7.0.0 have the following issues
- python-pillow/Pillow#4518
- python-pillow/Pillow#4509
@hugovk
Copy link
Member

hugovk commented Apr 6, 2020

We've merged a fix (#4528) for the new bug (#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!

@tlambert03
Copy link

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!

@radarhere
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants