ImageSequence模块包括了一个wrapper类,它能够让用户迭代訪问图形序列中每一帧图像。

一、ImageSequence模块的函数

1、 
Iterator

定义:ImageSequence.Iterator(image)
⇒ Iterator instance

含义:创建一个迭代器实例,让用户循环訪问序列中的全部帧图像。

样例:见以下的样例。

二、ImageSequence模块的方法

1、 
Operator

定义:Operator []

含义:用户调用这个操作器,从0開始訪问。

当没有其它帧图像时。这个迭代器将产生一个IndexError异常。

样例:

from PIL import Image, ImageSequence

im = Image.open("D:\\Code\\Python\\test\\img\\test01.gif")

index = 1
for frame in ImageSequence.Iterator(im):
print "image: index %d, mode %s, size %s" % (index, frame.mode, frame.size)
frame.save("frame%d.png" % index)
index = index + 1 iter = ImageSequence.Iterator(im)
print "image 10: mode %s, size %s" % (iter[10].mode, iter[10].size)
iter[10].show()

图像test01.gif为多张动态图像。

通过函数ImageSequence.Iterator(im)获取了图像对象im的迭代器,然后从当中逐张取出每张图片。打印了它们的模式和尺寸。后面通过操作符[]获取迭代器中的相应图像。iter[10]相应着第十张图像。

该程序输出例如以下:

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 10, mode P, size (450, 450)

image:index 11, mode P, size (450, 450)

image:index 12, mode P, size (450, 450)

image:index 13, mode P, size (450, 450)

image:index 14, mode P, size (450, 450)

image:index 15, mode P, size (450, 450)

image:index 16, mode P, size (450, 450)

image:index 17, mode P, size (450, 450)

image:index 18, mode P, size (450, 450)

image:index 19, mode P, size (450, 450)

image:index 20, mode P, size (450, 450)

image:index 21, mode P, size (450, 450)

image:index 22, mode P, size (450, 450)

image:index 23, mode P, size (450, 450)

image10: mode P, size (450, 450)

图像test01.gif例如以下:

当中第二张图像为:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

当中第二十张图像为:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

后面通过操作符[]获取的第十张图像例如以下:

Python图像处理库PIL的ImageSequence模块介绍的更多相关文章

  1. Python图像处理库PIL的ImageStat模块介绍

    ImageStat模块用于计算整个图像或者图像的一个区域的统计数据. 一.ImageStat模块的函数 1.  Stat 定义1:ImageStat.Stat(image)⇒ Stat instanc ...

  2. python图像处理库PIL的基本概念介绍

    PIL中所涉及的基本概念有如下几个:通道(bands).模式(mode).尺寸(size).坐标系统(coordinate system).调色板(palette).信息(info)和滤波器(filt ...

  3. Python图像处理库PIL中图像格式转换(一)

    在数字图像处理中,针对不同的图像格式有其特定的处理算法. 所以,在做图像处理之前,我们须要考虑清楚自己要基于哪种格式的图像进行算法设计及事实上现.本文基于这个需求.使用python中的图像处理库PIL ...

  4. Python图像处理库PIL中图像格式转换

    o 在数字图像处理中,针对不同的图像格式有其特定的处理算法.所以,在做图像处理之前,我们需要考虑清楚自己要基于哪种格式的图像进行算法设计及其实现.本文基于这个需求,使用python中的图像处理库PIL ...

  5. Python图像处理库——PIL

    PIL全称Python Image Library,是python官方的图像处理库,包含各种图像处理模块.Pillow是PIL的一个派生分支,包含与PIL相同的功能,并且更灵活.python3.0之后 ...

  6. Python图像处理库(PIL)

    官方:(详细)http://pillow.readthedocs.io/en/3.1.x/reference/ImageDraw.html http://pillow.readthedocs.io/e ...

  7. Python图像处理库PIL从入门到精通

    https://blog.csdn.net/column/details/pythonpil.html 示例: from PIL import Image import pytesseract pyt ...

  8. Python图像处理库:PIL中Image,ImageDraw等基本模块介绍

    Python图像处理库:PIL中Image,ImageDraw等基本模块介绍 标签: 图像处理PILPYTHON 2016-08-19 10:58 461人阅读 评论(0) 收藏 举报  分类: 其他 ...

  9. Python图像处理库:Pillow 初级教程

    Python图像处理库:Pillow 初级教程 2014-09-14 翻译 http://pillow.readthedocs.org/en/latest/handbook/tutorial.html ...

随机推荐

  1. C++ string的用法

    之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必担心内存是否足够.字符串长度等等,而且作为一个类出现,他集成的操作函数足以完成我们大多数情况下(甚至是 ...

  2. VS15 Visual Assist X破解

    Visual Assist X是一款非常好的Microsoft Visual Studio插件,支持C/C++,C#,ASP,Visual Basic,Java和HTML等语言,Visual Assi ...

  3. JDK Logger 简介 (zhuan)

    http://antlove.iteye.com/blog/1924832 ******************************************* 一 简述 java.util.log ...

  4. [转]解决 Eclipse项目红感叹号

    原文地址:http://www.cnblogs.com/hakuci/archive/2012/01/06/2314143.html 原因:显示红色感叹号是因为jar包的路径不对 解决:在项目上右击B ...

  5. SharePoint自动化系列——Upload files to SharePoint library using PowerShell.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 日常的SharePoint站点测试中,我们经常要做各种各样的数据,今天又写了几个脚本,发现自己写的 ...

  6. 面试-SizeOf一个对象会得到什么?

    相关资料: 1.https://zhidao.baidu.com/question/283124338.html unit Unit1; interface uses Windows, Message ...

  7. C语言 · 核桃的数量

    历届试题 核桃的数量   时间限制:1.0s   内存限制:256.0MB        锦囊1 最小公倍数. 锦囊2 答案是a, b, c的最小公倍数.   问题描述 小张是软件项目经理,他带领3个 ...

  8. [app]温度传感器测试程序

    刚开始去读/dev/i2c-1, 但是在设置地址的时候,始终错误,返回-1, 所以最后还是用了sys接口 /******************************************* * ...

  9. win7、vs2013编译webkit总结

    在windows7.vs2013环境下编译webkit,本人测试成功 1.解压cygwin到C盘下(建议放在C盘更目录下,否则编译期间会有部分文件找不到) 启动命令:C:\cygwin\bin\min ...

  10. 云端中间层负载均衡工具 Eureka

    亚马逊提供了一个负载均衡工具 Elastic Load Balancer,但针对的是终端用户 Web 流量服务器,而 Eureka 针对的是中间层服务器的负载均衡.AWS 固有的环境,对 IP 地址. ...