我得到了组合 png 文件以创建 gif 的代码。我已经让它在另一台使用不同 png 文件的计算机上工作,但是当我可以在另一个项目上使用它时,我得到一个我不明白的错误(我还在学习)。任何人都可以帮忙吗?错误读取
imageio.mimsave(output_filename, images, duration=seconds_per_frame)
Traceback (most recent call last):
File "<ipython-input-10-3af112267c62>", line 1, in <module>
imageio.mimsave(output_filename, images,
duration=seconds_per_frame)
File "C:\Users\ashleyp\AppData\Local\Continuum\anaconda3\lib\site-
packages\imageio\core\functions.py", line 363, in mimwrite
raise RuntimeError("Zero images were written.")
RuntimeError: Zero images were written.
我在正确的工作目录中,代码似乎可以运行到最后一行。我尝试更改 png 文件名以匹配我过去使用的文件名,但这并没有帮助。我在 GitHub 的 Imageio 的用户 API 上寻求帮助,但一无所获。Program creek 有一段类似的代码,从它的投票来看似乎运行良好,但我认为与我的没有显着差异。
我使用的代码如下,但我没有写。
#set the data directory
data_dir = r'F:\PhD\Working Files\Surfer\Months\JPEGs\PNGS'
import glob # To list files in directory.
import imageio # To read and write image files.
# Configuration parameters.
output_filename = 'out.gif'
seconds_per_frame = 0.25
filenames = sorted(glob.glob('*.png'))
images = [imageio.imread(filename) for filename in filenames]
imageio.mimsave(output_filename, images, duration=seconds_per_frame)
我希望输出是一个包含 12 帧的 gif 文件。错误读取
imageio.mimsave(output_filename, images, duration=seconds_per_frame)
Traceback (most recent call last):
File "<ipython-input-10-3af112267c62>", line 1, in <module>
imageio.mimsave(output_filename, images,
duration=seconds_per_frame)
File "C:\Users\ashleyp\AppData\Local\Continuum\anaconda3\lib\site-
packages\imageio\core\functions.py", line 363, in mimwrite
raise RuntimeError("Zero images were written.")
RuntimeError: Zero images were written.