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:

 

                            ftp://help:help@222.68.182.226/gif2.gif

 

                   several frames are wrong(See png_ok and png_wrong)

 

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

                   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?

         BR,

Lixin Song

=======================================================================

#!/usr/bin/env python

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

 

import Image

 

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

 

def iter_frames(im):

    try:

        i= 0

        while 1:

            im.seek(i)

            imframe = im.copy()

            if i == 0: 

                palette = imframe.getpalette()

            else:

                imframe.putpalette(palette)

            yield imframe

            i += 1

    except EOFError:

        pass

 

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

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

 

_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to