Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.
In this article, we will learn how to resize an image using python in Tkinter. In Tkinter, there is no in-built method or any package to work with images. Here we will use pillow library for images.
Let’s Understand step by step implementation:-
- Import Required Libary
- Read the image using the open() method in pillow libary
Image.open("Enter Image File Path", mode='r', **attr)
- Resize an image using resize() method. It returns a resized copy of this image.
Image.resize((width,height) , resample=3, **attr)
- Add Label and add resized image
Below is the implementation:
In the above example, enter the file name or path at the Image File Path and enter the value of width and height according to your need.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course