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

Calling im.convert() after accessing im.is_animated on gives an error with specific gifs #6605

Closed
ranetp opened this issue Sep 21, 2022 · 1 comment

Comments

@ranetp
Copy link

ranetp commented Sep 21, 2022

What did you do?

Tried to call im.convert() after accessing im.is_animated on a non-animated gif file.

What did you expect to happen?

Expected the im.convert() command to execute successfully.

What actually happened?

im.convert() gave an error 'NoneType' object has no attribute 'convert'

What are your OS, Python and Pillow versions?

  • OS: Windows 10 (build 19041.388)
  • Python: 3.7.6
  • Pillow: 9.2.0
im = Image.open('test.gif')
im.is_animated # is_animated was accessed, the next line calling .convert() will now fail
im.convert() # This gives "'NoneType' object has no attribute 'convert'"

If you call im.convert() without first calling im.is_animated, it will work fine.
This seemingly doesn't happen with every gif, including probably non animated ones.

I went through every line of the is_animated method in GifImagePlugin.py and it seems that the convert() error starts happening when an exception is thrown when calling self._seek(1, False) on line 134

test.gif which was used to produce the bug:
test

@radarhere radarhere changed the title Calling im.convert() after accessing im.is_animated on gives an error with specific gifs. Calling im.convert() after accessing im.is_animated on gives an error with specific gifs Sep 22, 2022
@radarhere radarhere added the GIF label Sep 22, 2022
@radarhere
Copy link
Member

Hi. This has actually already been fixed in main by PR #6455 (so this is effectively a duplicate of #6454). It will be part of the next Pillow release, due out in late October.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants