Concept

Animation formats

Animation formats are taken in as image sequences, and supported formats include GIF, FLI/FLC, and TIFF files. PIL contains basic support for image sequences such as reading sequences and iterating through the sequence.

To read a sequence:

from PIL import Image with Image.open("animation.gif") as im: im.seek(1) # skip to the second frame try: while 1: im.seek(im.tell()+1) # do something to im except EOFError: pass # end of sequence

To use the iterator class:

from PIL import ImageSequence for frame in ImageSequence.Iterator(im): # ...do something to frame...

0

1

Updated 2021-07-20

Tags

Python Programming Language

Data Science