Skip to content

Instantly share code, notes, and snippets.

@Creased
Forked from revolunet/extractGifs.py
Created November 23, 2017 14:33
Show Gist options
  • Save Creased/a34bc3b33ed7d81f4447212835d43548 to your computer and use it in GitHub Desktop.
Save Creased/a34bc3b33ed7d81f4447212835d43548 to your computer and use it in GitHub Desktop.
extract frames from animated gif using python+PIL
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('ban_ccccccccccc.gif', 'output')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment