diff --git a/PIL/ImageSequence.py b/PIL/ImageSequence.py index e94ca0b1e..513c9247b 100644 --- a/PIL/ImageSequence.py +++ b/PIL/ImageSequence.py @@ -14,15 +14,18 @@ # ## -# This class implements an iterator object that can be used to loop -# over an image sequence. class Iterator: + """ + This class implements an iterator object that can be used to loop + over an image sequence. - ## - # Create an iterator. - # - # @param im An image object. + You can use the ``[]`` operator to access elements by index. This operator + will raise an :py:exc:`IndexError` if you try to access a nonexistent + frame. + + :param im: An image object. + """ def __init__(self, im): if not hasattr(im, "seek"): diff --git a/docs/PIL.rst b/docs/PIL.rst index a4c709719..10774bcc7 100644 --- a/docs/PIL.rst +++ b/docs/PIL.rst @@ -86,14 +86,6 @@ can be found here. :undoc-members: :show-inheritance: -:mod:`ImageSequence` Module ---------------------------- - -.. automodule:: PIL.ImageSequence - :members: - :undoc-members: - :show-inheritance: - :mod:`ImageShow` Module ----------------------- diff --git a/docs/reference/ImageSequence.rst b/docs/reference/ImageSequence.rst new file mode 100644 index 000000000..85539cb9e --- /dev/null +++ b/docs/reference/ImageSequence.rst @@ -0,0 +1,27 @@ +.. py:module:: PIL.ImageSequence +.. py:currentmodule:: PIL.ImageSequence + +:py:mod:`ImageSequence` Module +============================== + +The :py:mod:`ImageSequence` module contains a wrapper class that lets you +iterate over the frames of an image sequence. + +Extracting frames from an animation +----------------------------------- + +.. code-block:: python + + from PIL 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 + +The :py:class:`~PIL.ImageSequence.Iterator` class +------------------------------------------------- + +.. autoclass:: PIL.ImageSequence.Iterator diff --git a/docs/reference/index.rst b/docs/reference/index.rst index 925487781..929ac099e 100644 --- a/docs/reference/index.rst +++ b/docs/reference/index.rst @@ -18,4 +18,5 @@ Reference ImagePalette ImagePath ImageQt + ImageSequence ../PIL