Skip to content

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

Closed

Description

@parano

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

Activity

  1. hugovk commented on Apr 1, 2020

    @hugovk
    Member

    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!

  2. changed the title [-]Issue reading PNG files[/-] [+]ImageIO: AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'[/+] on Apr 1, 2020
  3. hugovk commented on Apr 1, 2020

    @hugovk
    Member

    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):
  4. added
    Bug
    on Apr 1, 2020
  5. tlambert03 commented on Apr 1, 2020

    @tlambert03

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

  6. changed the title [-]ImageIO: AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'[/-] [+]AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame'[/+] on Apr 1, 2020
  7. hugovk commented on Apr 1, 2020

    @hugovk
    Member

    Possible fix: #4512.

  8. pmrowla commented on Apr 2, 2020

    @pmrowla
    Contributor

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

  9. SteveDoyle2 commented on Apr 2, 2020

    @SteveDoyle2

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

  10. hugovk commented on Apr 2, 2020

    @hugovk
    Member

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

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

  11. hugovk commented on Apr 2, 2020

    @hugovk
    Member

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

    Thanks all!

  12. tlambert03 commented on Apr 2, 2020

    @tlambert03

    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)

  13. hugovk commented on Apr 2, 2020

    @hugovk
    Member

    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.

  14. tlambert03 commented on Apr 2, 2020

    @tlambert03

    can do. thanks!

  15. nabobalis commented on Apr 3, 2020

    @nabobalis

    Moved to #4518

  16. hugovk commented on Apr 3, 2020

    @hugovk
    Member

    @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!

  17. added a commit that references this issue on Apr 6, 2020
  18. hugovk commented on Apr 6, 2020

    @hugovk
    Member

    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!

  19. tlambert03 commented on Apr 6, 2020

    @tlambert03

    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!

  20. radarhere commented on Apr 26, 2020

    @radarhere
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPNG

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions