Skip to content

Instantly share code, notes, and snippets.

@kwcooper
Last active April 13, 2019 06:02
Show Gist options
  • Save kwcooper/3764e504a96bebe266d12b2953981c4c to your computer and use it in GitHub Desktop.
Save kwcooper/3764e504a96bebe266d12b2953981c4c to your computer and use it in GitHub Desktop.
Takes images from a directory and builds a movie from them
# make a movie from images
import glob
import imageio
import os
path_name = "img/*.png"
# grab files, sorted by modification time
#filenames = glob.glob("img/*.png")
filenames = sorted(glob.glob(path_name), key=os.path.getmtime)
# compile frames into imageio objects
print('Making movie, may take a sec...')
images = []
for filename in filenames:
images.append(imageio.imread(filename))
# save that bad boy
imageio.mimsave('movie.gif', images)
print('fin')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment