Thursday, October 2, 2025
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

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11928 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS