Given an image the task here is to generate a Python script to flip an image horizontally and vertically. Here the module used for the task is PIL and transpose() function of this module.
Keywords FLIP_TOP_BOTTOM and FLIP_LEFT_RIGHT will be passed to transpose method to flip it.
- FLIP_TOP_BOTTOM – returns an original image flipped Vertically
- FLIP_LEFT_RIGHT- returns an original image flipped Horizontally
- Import module
- Open original image
- Transform the image as required
- Save the new transformed image.
Image in use:
Example: Flipping image vertically
Example : Flip image horizontally
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.