Resize GIF animation, pil/imagemagick, python

不问归期 提交于 2019-12-02 18:37:03
fraxel

You can use PIL and images2gif, a short PIL based module linked to on this blog page, and available here. Code used to process this rose.gif is below. I set the images2gif.readGif 'read as numpy array' property to false in order to get a list of PIL images so as I could use the PIL thumbnail function.

Orignial:

Processed:

import Image
import images2gif

frames = images2gif.readGif("rose.gif",False)
for frame in frames:
    frame.thumbnail((100,100), Image.ANTIALIAS)

images2gif.writeGif('rose99.gif', frames)

I'm not sure how to preserve transparency, my attempts to do so have failed (so far).

Some amazing person made an updated version of images2gif.py that accounts for transparency:

https://bitbucket.org/bench/images2gif.py/overview

There are still some artifacts, but it's way better than the original!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!