making gif from images using imageio in python

后端 未结 2 937
悲&欢浪女
悲&欢浪女 2021-02-04 05:25

I have tried reading a lot of examples online and found imageio is the perfect package for it. Also found examples written in here.

I have just followed

相关标签:
2条回答
  • 2021-02-04 06:14

    This works for me:

    import os
    import imageio
    
    png_dir = '../saves/png/'
    images = []
    for file_name in os.listdir(png_dir):
        if file_name.endswith('.png'):
            file_path = os.path.join(png_dir, file_name)
            images.append(imageio.imread(file_path))
    imageio.mimsave('../saves/gif/movie.gif', images)
    
    0 讨论(0)
  • 2021-02-04 06:25

    in case anyone needs it, for python 3.6.8, it needed fps

    imageio.mimsave('/path/file.gif',images,fps=55)
    
    0 讨论(0)
提交回复
热议问题