making gif from images using imageio in python

后端 未结 2 996
悲&欢浪女
悲&欢浪女 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)
    

提交回复
热议问题