调整大小动画GIF的Python问题

时间:2010-05-24 09:46:27

标签: python animation python-imaging-library gif

我想通过保存动画来调整动画GIF的大小。我尝试使用PIL和PythonMagickWand(ImageMagick)并使用一些GIF得到坏帧。当我使用PIL时,它在阅读框架中框架。为了测试,我使用这段代码:

from PIL import Image  
im = Image.open('d:/box_opens_closes.gif')
im.seek(im.tell()+1)
im.seek(im.tell()+1)
im.seek(im.tell()+1)
im.show()

当我在这段代码中使用MagickWand时:

wand = NewMagickWand()
MagickReadImage(wand, 'd:/Box_opens_closes.gif')
MagickSetLastIterator(wand)
length = MagickGetIteratorIndex(wand)
MagickSetFirstIterator(wand)
for i in range(0, length+1):
    MagickSetIteratorIndex(wand,i)
    MagickScaleImage(wand, 87, 58)  
MagickWriteImages(wand, 'path', 1)

我的GIF在哪里弄错了:test gif

在GIF编辑器软件中,所有帧都可以。问题出在哪儿?感谢。

1 个答案:

答案 0 :(得分:0)

我完成了这个。必须使用:


wand2 = MagickCoalesceImages(wand)
MagickWriteImages(wand2, 'save_path', 1)
相关问题