Python:Pillow .transpose()
Published Jun 28, 2024Updated Mar 21, 2025
Contribute to Docs
In Pillow, the .transpose() method is used to flip or rotate an image in 90-degree steps.
Syntax
Image.transpose(method)
Image: Refers to the image object to which the transpose operations are to be applied.method: Specifies the type of transpose operation to perform. It can take one of the following values:Image.FLIP_LEFT_RIGHT: Flips the image horizontally (left to right).Image.FLIP_TOP_BOTTOM: Flips the image vertically (top to bottom).Image.ROTATE_90: Rotates the image by 90 degrees anticlockwise.Image.ROTATE_180: Rotates the image by 180 degrees.Image.ROTATE_270: Rotates the image by 270 degrees anticlockwise.Image.TRANSPOSE: Transposes the image, which swaps the image’s rows and columns.Image.TRANSVERSE: Performs a diagonal flip from the bottom-left to the top-right of the image.
Example
The following example demonstrates the use of the .transpose() method:
import PILfrom PIL import Image# Read the imageim = Image.open("bird-thumbnail.jpg")# Display the original imageim.show()# Flip imageout = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)# Display the flipped imageout.show()
Original Image:
![]()
Flipped Image:

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python:Pillow on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn to clean, analyze, and visualize data with Python and SQL.
- Includes 15 Courses
- With Certificate
- Beginner Friendly.55 hours