Wednesday, June 17, 2026
HomeLanguagesPython PIL | Image.thumbnail() Method

Python PIL | Image.thumbnail() Method

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.thumbnail() Make this image into a thumbnail. This method modifies the image to contain a thumbnail version of itself, no larger than the given size. This method calculates an appropriate thumbnail size to preserve the aspect of the image, calls the draft() method to configure the file reader (where applicable), and finally resizes the image.

Note that this function modifies the Image object in place. If you need to use the full resolution image as well, apply this method to a copy() of the original image.

Syntax: Image.thumbnail(size, resample=3)

Parameters:
size – Requested size.
resample – Optional resampling filter.

Returns Type: An Image object.

Image Used:




   
  
# importing Image class from PIL package 
from PIL import Image
   
# creating a object 
image = Image.open(r"C:\Users\System-Pc\Desktop\python.png")
MAX_SIZE = (100, 100)
  
image.thumbnail(MAX_SIZE)
  
# creating thumbnail
image.save('pythonthumb.png')
image.show()


Output:

Another Example:Here used another image.

Image Used:




   
  
# importing Image class from PIL package 
from PIL import Image
   
# creating a object 
image = Image.open(r"C:\Users\System-Pc\Desktop\house.jpg")
MAX_SIZE = (500, 500)
  
image.thumbnail(MAX_SIZE)
  
# creating thumbnail
image.save('pythonthumb2.jpg')
image.show()


Output:

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS