Gif partially lose transparency / misalign, not on all frames #2239

Nitaym opened this Issue Nov 22, 2016 · 1 comment


None yet

3 participants

Nitaym commented Nov 22, 2016 edited

I'm building a script to extract a frame from a gif, and encountered a bug (I think).
The script is working properly with several gifs I've tried it on, but this specific gif I'm getting weird misalignments and transparency issues.

This is the original gif

And this is the output from frame 10:

This happens on almost every frame.

Here's the python code to extract the frame:

with open('loading.gif', "rb") as f:
    gif_data = bytearray(

    # gif =
    gif =
    width, height = gif.size
except IOError as e:
    print "Cant load", gif_data

mypalette = gif.getpalette()

sprite ="RGBA", (width, height))
for i in range(10): + 1)

sprite.paste(gif, (0, 0, width, height))

sprite_data = io.BytesIO() , format='PNG')
sprite_data = sprite_data.getvalue()

with open('sprite.png', 'wb') as f:
    # png_base64 = (json.load(io.BytesIO(converted)))['file']
    # png = base64.b64decode(png_base64)
    print "File written"

That one is weird. I've never seen imagemagick's display have a fully transparent window before.

It's going to take some digging, but I'm suspecting that some of the trouble comes from having the first frame not actually cover the entire size of the gif.

@aclark4life aclark4life added this to the Future milestone Jan 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment