我已经尝试过这个:
from PIL import Image
im = Image.open('this.webp')
im.save('that.gif', 'gif', save_all=True)
Run Code Online (Sandbox Code Playgroud)
这给了我这个错误
类型错误:& 不支持的操作数类型:“tuple”和“int”
我的网站上有数百张 webp 图像,需要将它们转换为 gif,因为 Firefox 不支持它。谢谢。
我正在寻找一种获得gif帧数的方法.我正在寻找谷歌,stackoverflow和任何外部网站,我只发现垃圾!有人知道怎么做吗?我只需要简单数量的gif帧.
我试图从我的gif图像显示动画.从我之前的问题,我发现Tkinter不会自动为图像制作动画.我的Tk界面显示图像的第一帧,当我点击按钮播放动画时,它什么也没做.这可能与与按钮关联的命令有关.这是代码:
from Tkinter import *
import Tkinter
root = Tk()
photo_path = "/users/zinedine/downloads/091.gif"
photo = PhotoImage(
file = photo_path
)
def run():
frame = 1
while True:
try:
photo = PhotoImage(
file = photo_path,
format = "gif - {}".format(frame)
)
frame = frame + 1
except Exception: # This because I don't know what exception it would raise
frame = 1
break
picture = Label(image = photo)
picture.pack()
picture.configure(run())
animate = Button(
root,
text = "animate",
command = …Run Code Online (Sandbox Code Playgroud) 我想使用python3和tkinter创建一个虚拟的宠物风格游戏。到目前为止,我已经有了主窗口并开始放入标签,但是我遇到的问题是播放动画gif。我在这里搜索并找到了一些答案,但是他们不断抛出错误。我发现使用PhotoImage的结果具有gif的索引位置,并在一定范围内继续。
# Loop through the index of the animated gif
frame2 = [PhotoImage(file='images/ball-1.gif', format = 'gif -index %i' %i) for i in range(100)]
def update(ind):
frame = frame2[ind]
ind += 1
img.configure(image=frame)
ms.after(100, update, ind)
img = Label(ms)
img.place(x=250, y=250, anchor="center")
ms.after(0, update, 0)
ms.mainloop()
Run Code Online (Sandbox Code Playgroud)
当我在终端中使用“ pyhton3 main.py”运行此命令时,出现以下错误:
_tkinter.TclError:该索引没有图像数据
我俯视什么或完全忽略了什么?
这是查看完整项目的GitHub存储库的链接:VirtPet_Python
提前致谢!