Flip horizontally, vertically, and rotate

Here we look at a set of quick and easy transformations that are typical of the operations we would need in a photo viewer.

Getting ready

Use the image dusi_leo_1.jpg from the folder /constr/pics1.

How to do it...

Execute the following program and see the results in /constr/picsx.

# image_flips_1.py
#>>>>>>>>>>>>>>
import Image
im_1 = Image.open("/a_constr/pics1/dusi_leo_1.jpg")
im_out_1 = im_1.transpose(Image.FLIP_LEFT_RIGHT)
im_out_2 = im_1.transpose(Image.FLIP_TOP_BOTTOM)
im_out_3 = im_1.transpose(Image.ROTATE_90)
im_out_4 = im_1.transpose(Image.ROTATE_180)
im_out_5 = im_1.transpose(Image.ROTATE_270)
im_out_1.save("/a_constr/picsx/dusi_leo_horizontal.jpg")
im_out_1.save("/a_constr/picsx/dusi_leo_vertical.jpg")
im_out_1.save("/a_constr/picsx/dusi_leo_90.jpg")
im_out_1.save("/a_constr/picsx/dusi_leo_180.jpg")
im_out_1.save("/a_constr/picsx/duzi_leo_270.jpg")

How it works...

The preceding commands are self-explanatory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.239.118