I have tried reading a lot of examples online and found imageio is the perfect package for it. Also found examples written in here.
imageio
I have just followed
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)