Skip to content

Commit 753b2da

Browse files
committed
mirror function
1 parent 6af65ac commit 753b2da

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Image_Processing/src/basics/mirror.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding: utf8
2+
# Author: Oriol Vall
3+
4+
from PIL import Image
5+
6+
#FLIP AN IMAGE
7+
8+
def mirror(image_path, direction):
9+
image_obj = Image.open(image_path)
10+
if direction == 'h': # Horizontal
11+
rotated_image = image_obj.transpose(Image.FLIP_LEFT_RIGHT)
12+
elif direction == 'v':
13+
rotated_image = image_obj.transpose(Image.FLIP_TOP_BOTTOM)
14+
rotated_image.show()
15+
16+
if __name__ == '__main__':
17+
image = 'test.jpg'
18+
mirror(image, 'h')
19+
mirror(image, 'v')

0 commit comments

Comments
 (0)