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
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)
in case anyone needs it,
for python 3.6.8, it needed fps
imageio.mimsave('/path/file.gif',images,fps=55)