Python枕头透明gif无法正常工作 [英] Python Pillow transparent gif isn't working

查看:71
本文介绍了Python枕头透明gif无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试旋转以下图标的gif:

I am trying to make a gif of the following icon rotating :

要尝试实现这一点,我正在使用Pillow库在Python中运行以下代码:

To attempt to achieve this I am running the following code in Python using the Pillow library :

from PIL import Image, ImageDraw

images = []

icon = Image.open("cameraIcon.png")

for i in range(0, 360):
    images.append(icon.rotate(i))

images[0].save('loadingIcon.gif', format='GIF', save_all=True, append_images=images[1:], duration=40, loop=0, transparency=0)

但是此代码的输出与我想要的不匹配,我得到以下gif:

However the output of this code does not match what I want, I get the following gif :

我不知道发生了什么,感谢您的帮助.

I don't know what is happening and would appreciate any help, thank you.

推荐答案

我在使用PIL时也遇到了麻烦,因此这是一个 ImageMagick 解决方案,可让您在继续工作的同时继续前进...

I am having trouble doing it with PIL too, so here is an ImageMagick solution to keep you going while I work on it...

for ((i=0;i<360;i+=5)) ; do 
   magick camera.png -virtual-pixel transparent -distort SRT "41 41 $i" miff:-
done | magick -background none -dispose background -delay 20 miff:- anim.gif

这篇关于Python枕头透明gif无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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