Open In App

Python PIL | Image.seek() Method

Improve
Improve
Like Article
Like
Save
Share
Report

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.

Image.seek() Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an EOFError exception. When a sequence file is opened, the library automatically seeks to frame 0.

Note that in the current version of the library, most sequence formats only allows you to seek to the next frame.

Syntax: Image.seek(frame)

Parameters:
frame – Frame number, starting at 0.

Raises: EOFError – If the call attempts to seek beyond the end of the sequence.

Image Used:




   
  
# 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()


Output:

0
1


Last Updated : 02 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads