当前位置:   article > 正文

python gif压缩_Python的问题,调整大小的GIF动画

python 生成gif图过大

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()

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)

My GIF where I'm get bad frame this: test gif

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)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/912994
推荐阅读
相关标签
  

闽ICP备14008679号