如何在python中播放GIF

问题描述 投票:0回答:1

感谢您提前帮助我

我有一个gif文件说sample.gif,我想在我的.ipynb中显示此GIF文件,或者不打开新窗口,却拥有一系列的.gif文件,并且我正在创建子图来显示gif,但无法显示找到更好的解决方案

我看到pyglet,但是它会打开新窗口以显示gif。由于我只有GIF文件,因此我认为这里没有提供代码

感谢您的帮助

编辑:尝试下面的代码将给出错误:TypeError: Image data of dtype <U10 cannot be converted to float

import matplotlib.pyplot as plt
plt.imshow('sample.gif', cmap='gray')
python matplotlib deep-learning computer-vision gif
1个回答
0
投票

我找到了一种使用Ipython.display.Image做到这一点的方法,但它并未在子图中绘制,而是在垂直方向上显示了所有gif。谁能帮助我如何在Ipython.display.Image

上应用子图
with open('sample.gif','rb') as f:
  display(Image(data=f.read(),format="png",width =150,height=150))
© www.soinside.com 2019 - 2024. All rights reserved.