The Wayback Machine - https://web.archive.org/web/20230501032730/https://www.geeksforgeeks.org/python-pil-image-seek-method/
Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python PIL | Image.seek() Method

Improve Article
Save Article
Like Article
author
Sunitamamgai
scholar
67 published articles
Improve Article
Save Article
Like Article

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

My Personal Notes arrow_drop_up
Last Updated : 02 Aug, 2019
Like Article
Save Article
Similar Reads
Related Tutorials