Python的问题,调整大小的GIF动画 [英] Python problem with resize animate GIF

查看:1739
本文介绍了Python的问题,调整大小的GIF动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要调整GIF动画用保存动画。我尝试使用PIL和PythonMagickWand(ImageMagick的),并与一些GIF的得到坏帧。当我使用PIL,它在三月阅读框框架。对于测试中,我用这个code:

I'm want to resize animated GIF with save animate. I'm try use PIL and PythonMagickWand (ImageMagick) and with some GIF's get bad frame. When I'm use PIL, it mar frame in read frame. For test, I'm use this code:

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这个code:

When I'm use MagickWand with this code:

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在那里我得到坏帧这样的:测试的gif

在GIF编辑软件,所有的帧都OK。哪里有问题?谢谢你。

In GIF editor software, all frames are ok. Where is the problem? Thanks.

推荐答案

我完全这一点。必须使用:

I'm complete this. Must use:


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

这篇关于Python的问题,调整大小的GIF动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆