back next

The ImageSequence Module

The ImageSequence module contains a wrapper class that lets you iterate over the frames of an image sequence.

Extracting frames from an animation
import Image, ImageSequence

im = Image.open("animation.fli")

index = 1
for frame in ImageSequence.Iterator(im):
    frame.save("frame%d.png" % index)
    index = index + 1

Functions #

Iterator #

ImageSequence.Iterator(image) ⇒ Iterator instance

Creates an Iterator instance that lets you loop over all frames in a sequence.

Methods #

The Iterator class implements the [] operator:

Operator []

You can call this operator with integer values from 0 and upwards. The iterator raises an IndexError exception when there are no more frames.

 

[comment on/vote for this article]

A Django site. this page was rendered by a django application in 0.03s 2008-12-02 02:44:05.467648. hosted by webfaction.