Skip to content

Animated GIFs aren't correct after first frame and lost transparency #1976

@docapotamus

Description

@docapotamus

What did you do?

I open an animated GIF and immediately save it back out to another file.

What did you expect to happen?

The image to be the same as it was when it was uploaded.

What actually happened?

The transparency is gone on the first frame and all subsequent frames have a black background.

What versions of Pillow and Python are you using?

3.2.0

Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. The best reproductions are self-contained scripts with minimal dependencies.

banana
output

from PIL import Image                                                           
img = Image.open('banana.gif')
img.save('output.gif', format='GIF', save_all=True)

I am aware there are a lot of issues related to animated GIFs but I am struggling to get a coherent understanding of the issue.

I have other GIFs which act differently and just distort all subsequent frames.
otter
output

I am happy to provide any more information if needed. I'm willing to fix this myself if needs be. I just don't know enough about Pillow's internals or where to even start with an issue like this.

I forgot to add there is an error appearing which says a colour can't be found for transparent. I will post the actual error later when I am at my computer.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.GIFPalette

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions