Skip to content

Animated GIF frames rendered incorrectly #1742

@czablocki

Description

@czablocki

The attached animated .gif (bad.gif) is rendered incorrectly by PIL, with a lot of artifacts and noise in its frames (eg: bad_frame_2.gif). The same file plays correctly in web browsers and image viewers on Windows and Linux.

After uploading and re-downloading bad.gif from imgur.com, I got good.gif, which displays correctly in everything.

good.gif is slightly different in size and has slightly different color tables, but the part I'd expect to be important (transparency index and corresponding palette entry) is the same.

The only remarkable things about bad.gif that I noticed is the transparency index (0) maps to white (255,255,255) and it has NoDispose (1) as its dispose_method

Here's the test script:

from PIL import Image

image = Image.open("good.gif")
#image = Image.open("bad.gif")

#actually 18 frames long
for x in range(0, 2):
    image.seek(x)
    image.show()

bad.gif
bad
bad_frame_2

good.gif
good
good_frame_2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions