[Image-SIG] 答复: gif convert png wrong
宋立新(凡卓通讯)
songlixin at vanzotec.com
Tue Dec 20 10:48:27 CET 2011
Also I found that GIMP does not work, but Adobe Image Ready work.
发件人: 宋立新(凡卓通讯) [mailto:songlixin at vanzotec.com]
发送时间: 2011年12月20日 星期二 10:51
收件人: 'image-sig at python.org'
主题: gif convert png wrong
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20111220/cb5e0298/attachment-0001.html>
More information about the Image-SIG
mailing list