Created
August 17, 2011 12:18
-
-
Save revolunet/1151424 to your computer and use it in GitHub Desktop.
extract frames from gif animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from PIL import Image | |
| def extractFrames(inGif, outFolder): | |
| frame = Image.open(inGif) | |
| nframes = 0 | |
| while frame: | |
| frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF') | |
| nframes += 1 | |
| try: | |
| frame.seek( nframes ) | |
| except EOFError: | |
| break; | |
| return True | |
| extractFrames('animated.gif', 'output') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment