我对python很陌生,尝试使用它将GIF的帧分割成PNG图像。
# Using this GIF: http://www.videogamesprites.net/FinalFantasy1/Party/Before/Fighter-Front.gif
from PIL import Image
im = Image.open('Fighter-Front.gif')
transparency = im.info['transparency']
im.save('test1.png', transparency=transparency)
im.seek(im.tell()+1)
transparency = im.info['transparency']
im.save('test2.png', transparency=transparency)
# First frame comes out perfect, second frame (test2.png) comes out black,
# but in the "right shape", i.e.
# http://i.stack.imgur.com/5GvzC.png
这是因为我的工作形象,还是我做错了什么?
谢谢!
我已经在这里修复了这个bug https://code.launchpad.net/~asdfghjkl-deactivatedaccount1/python-imaging/gif-fix。
如果GIF使用本地颜色表,DSM的答案将不起作用。
我认为你没有做错什么。在这里可以看到类似的问题:animated GIF problem。看起来好像调色板信息在以后的帧中没有得到正确的处理。以下对我有效:
相关问题 更多 >
编程相关推荐