Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Basic Manipulations

00:00 Basic Image Manipulation. So far, you’ve performed cropping and resizing on your image, but Pillow can do much more. A common requirement is to rotate or flip an image.

00:13 You can use the .transpose() method for some transformations. To aid your muscle memory in using Pillow, start a new REPL session, import Pillow, and load the same image you used previously.

00:47 The code should display the image as seen on-screen.

00:52 There are seven options that you can pass as arguments to .transpose(), FLIP_LEFT_RIGHT, which flips the image left to right, resulting in a mirror image, FLIP_TOP_BOTTOM, which flips the image top to bottom, ROTATE_90, which rotates the image by 90 degrees counterclockwise.

01:09 ROTATE_180 and ROTATE_270 perform appropriate counterclockwise rotations. TRANSPOSE transposes the rows and columns using the top-left pixel as the origin, with the top-left pixel being the same in the transposed image as in the original image.

01:24 TRANSVERSE transposes the rows and columns using the bottom-left pixel as the origin, with the bottom-left pixel being the one that remains fixed between the original and modified versions.

01:35 All the rotation options define rotations in steps of 90 degrees. If you need to rotate an image by an arbitrary angle, then you can use the .rotate() method.

01:48 This method call rotates the image by 45 degrees counterclockwise, giving the image seen on-screen. The Image object returned is the same size as the original Image, and therefore, the corners of the image are missing in this display.

02:05 You can change this behavior by using the expand named parameter. This method returns a large image that fully contains the rotated image.

02:21 You can customize the rotation further with the additional optional parameters that are seen on-screen. You can now change the size and orientation of an image.

02:32 And in the next section of the course, you’ll learn about different types of images in the Pillow library. And this is an important area of knowledge as you increase your skills with Pillow.

Become a Member to join the conversation.