[英]How to show PIL Images as a movie?
I get continuously PIL Images, using while True
loop, and want to show them as a movie. 我使用while True
循环时连续获取PIL图像,并希望将它们显示为电影。
I can show an image by img.show()
, but this code inside the loop makes multiple windows. 我可以通过img.show()
显示图像,但是循环中的此代码可以创建多个窗口。
Would you tell me the way to display them as a movie? 您能告诉我如何将它们显示为电影吗?
I think the easiest way is to use ImageMagick in the command line to great a .gif
file with the following command, assuming your image files are named something like image-1.png
, image-2.png
: 我认为最简单的方法是在命令行中使用ImageMagick通过以下命令创建一个.gif
文件,假设您的图像文件命名为image-1.png
, image-2.png
:
sudo apt-get install imagemagick
convert -delay 20 -loop 0 image-*.png my_movie.gif
This will create a my_movie.gif
in the same directory where your images are located. 这将在图像所在的目录中创建my_movie.gif
。
Another way to create a movie from frames is to use Blender, an open source program based on Python. 从帧创建电影的另一种方法是使用Blender,这是一个基于Python的开源程序。 I don't think Pillow supports creating gifs or movie files directly; 我不认为Pillow支持直接创建gif或电影文件。 every solution I have seen involves some other library, so I think the best way is to go with a simple command line tool. 我见过的每个解决方案都涉及其他库,因此我认为最好的方法是使用简单的命令行工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.