Generate animated gif from images in python

#!/PATH/TO/PYTHON
#
# Generate an animated gif of the specified static images.

import imageio
import sys

if len(sys.argv) < 4:
    print('Usage: gif output.gif [frame duration in ms] [image1] [image2] ...')
    sys.exit(0)

output_fname = sys.argv[1]
duration = int(sys.argv[2])
fnames = sys.argv[3:]

images = []
for fname in fnames:
    images.append(imageio.imread(fname))
imageio.mimsave(output_fname, images, duration=duration/1000)

Posted by Abraham