[Image-SIG] gif convert png wrong

宋立新(凡卓通讯) songlixin at vanzotec.com
Tue Dec 20 03:50:41 CET 2011

Hello All:

       I am writing a python tool that covert gif to png so it can be used
for android ROM customization.

            My script is after the text, but it doesn’t work for some gifs,
such as the one at:




                   several frames are wrong(See png_ok and png_wrong)


                   And it’s not rare: 2 of my 7 gifs got wrong with the

                   While a tool named: “Ulead GIF Animator 5” under
windows can convert it without problem.


                   To be honest, imagemagick and another linux tool gif2png
also has the same problem. And Also AcdSee (Under Windows)!

                   I have no idea about this and I really wish to write a
tool to improve our efficiency.

                   Could some expert take a look on it?


Lixin Song


#!/usr/bin/env python

# -*- coding: utf-8 -*-


import Image


im = Image.open('gif2.gif')


def iter_frames(im):


        i= 0

        while 1:


            imframe = im.copy()

            if i == 0: 

                palette = imframe.getpalette()



            yield imframe

            i += 1

    except EOFError:



for i, frame in enumerate(iter_frames(im)):

    frame.save('test%d.png' % i,**frame.info)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20111220/de36b3c8/attachment-0001.html>

More information about the Image-SIG mailing list