Python Pillow透明gif不起作用 [英] Python Pillow transparent gif isn't working
本文介绍了Python Pillow透明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 Pillow透明gif不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文