O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating images with PIL

In order to use PIL, we will first need to install it. The version which I will be using is available on pip and can be installed with the following command:

pip install pillow

PIL provides multiple ways of resizing an image. Two possible methods we could use in our application are resize and thumbnail.

The resize method will alter an image to be the exact size provided to the method (as a two-tuple of width and height). On the other hand, the thumbnail method will preserve the aspect ratio of an image, preventing skew, resizing the larger dimension of the image to the provided maximum size, and keeping the smaller dimension at the same ratio. 

For my implementation of this application, I will be using the thumbnail ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required