The Wayback Machine - https://web.archive.org/web/20240610011849/https://www.geeksforgeeks.org/python-pil-image-thumbnail-method/
Open In App

Python PIL | Image.thumbnail() Method

Last Updated : 19 Jul, 2019
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.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:



Previous Article
Next Article

Similar Reads

Convert OpenCV image to PIL image in Python
OpenCV is a huge open-source library for computer vision, machine learning, and image processing. OpenCV supports a wide variety of programming languages like Python, C++, Java, etc. It can process images and videos to identify objects, faces, or even the handwriting of a human. When it is integrated with various libraries, such as Numpy which is a
3 min read
Generate square or circular thumbnail image with Python - Pillow
Prerequisites: Pillow, Numpy In the word "THUMBNAIL" the word THUMB means short. A thumbnail is the compressed preview image of the original image or a Thumbnail is the smaller version of an image. In simple words, the thumbnail is the smaller image that represents the larger/original image. Usually, the shape of the thumbnail is dependent on the o
6 min read
How to merge a transparent PNG image with another image using PIL?
This article discusses how to put a transparent PNG image with another image. This is a very common operation on images. It has a lot of different applications. For example, adding a watermark or logo on an image. To do this, we are using the PIL module in Python. In which we use some inbuilt methods and combine the images in such a way that it loo
2 min read
How to Convert PIL Image into pygame surface image?
In this article, we will know How to Convert PIL Image into pygame surface image. Pygame Surface Image: A surface that not only has fixed resolution and pixel format but also represents the image in Pygame is known as Pygame Surface Image. Are you constructing any game in Pygame in which you want to use only Pygame Surface Image as an input? As mos
4 min read
Python PIL | Image.crop() method
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. PIL.Image.crop() method is used to crop a rectangular portion of any image. Syntax: PIL.Image.crop(box = None)Parameters: box - a 4-tuple defining the left, upper, right, and lower pixel coordinate.Return type: Image (Returns a rectangular regio
2 min read
Python PIL | Image.new() method
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. PIL.Image.new() method creates a new image with the given mode and size. Size is given as a (width, height)-tuple, in pixels. The color is given as a single value for single-band images, and a tuple for multi-band images (with one value for each
2 min read
Python PIL | Image.split() method
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. Image.split() method is used to split the image into individual bands. This method returns a tuple of individual image bands from an image. Splitting an “RGB” image creates three new images each containing a copy of one of the original bands (re
1 min read
Python PIL | Image.open() 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. PIL.Image.open() Opens
2 min read
Python PIL | Image.point() 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.point() Maps this
2 min read
Python PIL | Image.show() 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.show() Displays th
1 min read
Article Tags :
Practice Tags :