【问题标题】:Python problem with resize animate GIF调整动画 GIF 大小的 Python 问题
【发布时间】:2011-02-23 04:09:26
【问题描述】:

我想通过保存动画来调整动画 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 编辑软件中,所有帧都可以。问题出在哪里?谢谢。

【问题讨论】:

标签: python animation python-imaging-library gif


【解决方案1】:

我已经完成了。必须使用:


wand2 = MagickCoalesceImages(wand)
MagickWriteImages(wand2, 'save_path', 1)

【讨论】:

    猜你喜欢
    • 2012-08-30
    • 2012-04-16
    • 2018-04-18
    • 2012-09-07
    • 1970-01-01
    • 2011-11-01
    • 2012-09-07
    • 1970-01-01
    • 2011-08-09
    相关资源
    最近更新 更多