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

Image.show() defaults to PNG ignoring animated GIFs #6608

Closed
seidnerj opened this issue Sep 22, 2022 · 3 comments · Fixed by #6610
Closed

Image.show() defaults to PNG ignoring animated GIFs #6608

seidnerj opened this issue Sep 22, 2022 · 3 comments · Fixed by #6610

Comments

@seidnerj
Copy link

seidnerj commented Sep 22, 2022

When using show() for an animated GIF with version 9.2.0, Pillow converts the image to PNG by default thus eliminating the animation.

I suggest the following change in "ImageShow.py" to preserve the animation:

def save_image(self, image):
    """Save to temporary file and return filename."""

    if image.format == 'GIF' and image.is_animated:
        suffix = "." + image.format
        f, filename = tempfile.mkstemp(suffix)
        os.close(f)

        image.save(filename, save_all=True)

        return filename
    else:
        image_format = self.get_format(image)
        return image._dump(format=image_format, **self.options)
@radarhere
Copy link
Member

PNG also supports multiple frames. If we were going to add this feature, I would recommend still using the PNG format, as GIF frames are limited to 256 colors.

@radarhere
Copy link
Member

I've created PR #6611 to do so, and PR #6610 to fix a problem when saving GIFs as animated PNGs.

@seidnerj
Copy link
Author

Hehe, I was just faced with what you fixed in #6610 when I tried rewriting this to work as an animated PNG and was working to fix that :)

Nice! thanks a lot.

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

Successfully merging a pull request may close this issue.

2 participants