Python PIL Image.seek()方法

Python PIL Image.seek()方法

PIL是Python图像库,它为Python解释器提供了图像编辑功能。图像模块提供了一个同名的类,用来表示一个PIL图像。该模块还提供了一些工厂函数,包括从文件加载图像和创建新图像的函数。

Image.seek()在这个序列文件中搜索到给定的帧。如果你的搜索超出了序列的末端,该方法会引发一个EOFError异常。当一个序列文件被打开时,该库会自动寻找到第0帧。

请注意,在当前版本的库中,大多数序列格式只允许你寻找到下一帧。

语法: Image.seek(frame)

参数:
frame – 帧号,从0开始。

引发: EOFError – 如果调用试图寻求超过序列的终点。

使用的图片:
Python PIL Image.seek()方法

# importing image class from PIL package
from PIL import Image
  
# creating gif image object
img = Image.open(r"C:\Users\System-Pc\Desktop\time.gif")
img1 = img.tell()
print(img1)
  
# using seek() method
img2 = img.seek(img.tell() + 1)
img3 = img.tell()
print(img3)
img.show()

输出:

0
1

Python PIL Image.seek()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程