Skip to content

Last frame of gif has second last frame merged to it #3153

@s0hv

Description

@s0hv

What did you do?

I iterated through gif frames and added copies of the frames converted to rgba to a list of the following 4 frame gif gif

This was the code I used and what produced the invalid result

frames = []
while True:
    frames.append(im.copy().convert('RGBA'))
    try:
        im.seek(im.tell() + 1)
    except EOFError:
        break

What did you expect to happen?

Expected that all the frames would look normal without them merging

What actually happened?

The last 2 images merged Invalid frame as in the following pic when the expected result would be Correct frame
The second last frame was kept normal but the last frame included the second last frame merged to it
I was able to get the desired result by using the following modification of my original loop

frames = []
while True:
    frames.append(im.copy().convert('RGBA'))
    try:
        im.seek(im.tell() + 1)
    except EOFError:
        frames[-1] = im.copy().convert('RGBA')
        break

What versions of Pillow and Python are you using?

Python 3.6.4
Pillow 5.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions