调整GIF动画,pil / imagemagick,python

编程入门 行业动态 更新时间:2024-10-25 05:19:36
本文介绍了调整GIF动画,pil / imagemagick,python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用python和PIL或PythonMagick更改GIF动画图像的大小。我找不到解决方案。 PIL和缩略图方法适用于jpg和png但不适用于gif。 ImageMagick有命令mogrify / convert -resize'1280x1024>'但我找不到文档,我不知道怎么用pythonmagick。

I want to change size of GIF animation image using python and PIL or PythonMagick. I can't find solution. PIL and thumbnail method works for jpg and png but not for gif. ImageMagick has command mogrify/convert -resize '1280x1024>' but i can't find documentation and i don't know how to do it with pythonmagick.

任何人都知道解决方案?

Anyone knows solution?

在最坏的情况下,我使用os / subprocess并转换; -S

In the worst case i use os/subprocess and convert ;-S

谢谢。

推荐答案

您可以使用PIL和 images2gif ,一个基于PIL的简短模块链接到这个博客页面,并提供此处。用于处理此 rose.gif 的代码如下。我将 images2gif.readGif '读为numpy数组'属性设置为 false 以获取PIL图像列表所以我可以使用PIL 缩略图函数。

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:已处理:

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

更多推荐

调整GIF动画,pil / imagemagick,python

本文发布于:2023-06-08 06:31:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/576150.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动画   GIF   pil   python   imagemagick

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!