Imagesequence module Introduction to Python image processing library pil

Source: Internet
Author: User
Tags image processing library

imagesequence The module includes a wrapper class that allows users to iterate through each frame of an image in a sequence of graphics.

function of the imagesequence Module

1. Iterator

Definition:imagesequence.iterator (image)? Iterator Instance

Meaning: Create an iterator instance that allows the user to iterate through all the frame images in the sequence.

Examples: see below for examples.

Second, the method of Imagesequence module

1. Operator

Definition: Operator []

Meaning: The user invokes the operator, starting from 0 .

When there is no other frame image. This iterator will produce a indexerror exception.

Examples:

From PIL import image, Imagesequenceim = Image.open ("d:\\code\\python\\test\\img\\test01.gif") index = 1for frame in Image Sequence.iterator (IM):    print "Image:index%d, mode%s, size%s"% (index, Frame.mode, frame.size)    Frame.save ("fr Ame%d.png "% index"    index = index + 1iter = Imagesequence.iterator (IM) print "Image 10:mode%s, size%s"% (iter[10].m Ode, Iter[10].size) Iter[10].show ()

The image is test01.gif as multiple dynamic images.

An iterator to the im of the image object is obtained through the function imagesequence.iterator (IM) , and each picture is taken out of one sheet. Their patterns and dimensions are printed. The corresponding image in the iterator is obtained later by the operator [] . iter[10] corresponds to the tenth image.

The program outputs such as the following:

Image:index 1, Mode P, size (450, 450)

Image:index 2, Mode P, size (450, 450)

Image:index 3, Mode P, size (450, 450)

Image:index 4, Mode P, size (450, 450)

Image:index 5, Mode P, size (450, 450)

Image:index 6, Mode P, size (450, 450)

Image:index 7, Mode P, size (450, 450)

Image:index 8, Mode P, size (450, 450)

Image:index 9, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image:index, Mode P, size (450, 450)

Image10:mode P, size (450, 450)

Image Test01.gif such as the following:

The second image is:

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">

The 20th image is:

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity /center ">

The tenth image obtained by the operator [] is followed by the following example:

Imagesequence module Introduction to Python image processing library pil

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.