Skip to content

Instantly share code, notes, and snippets.

@dguzzo
Last active April 6, 2017 02:13
Show Gist options
  • Save dguzzo/cecc2ef8b8b520af3dc40e209eadc183 to your computer and use it in GitHub Desktop.
Save dguzzo/cecc2ef8b8b520af3dc40e209eadc183 to your computer and use it in GitHub Desktop.
make an animated gif from some images with Wand
#!/usr/bin/env python3
from glob import glob
from wand.image import Image
source_images = glob("S*.png")
TOTAL_FRAMES = len(source_images)
print("animating %i files" % TOTAL_FRAMES )
with Image() as animation:
# Add new frames into sequance
for path in source_images:
with Image(filename=path) as new_frame:
new_frame.delay = 20
animation.sequence.append(new_frame)
# Set layer type
animation.type = 'optimize'
print("saving animation...")
animation.save(filename='animated-python.gif')
@dguzzo
Copy link
Author

dguzzo commented Oct 9, 2016

not flexible at all at the moment! for instance, the glob() parameter is hardcoded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment