Resizing images with ImageTk.PhotoImage with Tkinter

The PIL or Pillow library in Python is used for processing images in a Tkinter application. We can use Pillow to open the images, resize them and display in the window. To resize the image, we can use image_resize((width, height) **options) method. The resized image can later be processed and displayed through the label widget.


Let us have a look at the example where we will open an image and resize it to display in the window through the label widget.

# Import the required libraries
from tkinter import *
from PIL import Image, ImageTk

# Create an instance of tkinter frame or window

# Set the size of the tkinter window

# Load the image'download.png')

# Resize the image in the given (width, height)
img=image.resize((450, 350))

# Conver the image in TkImage

# Display the image with label
label=Label(win, image=my_img)



Running the above code will display a resized image in the window.

Updated on: 06-Aug-2021

14K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started