-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_convert.py
More file actions
36 lines (25 loc) · 744 Bytes
/
02_convert.py
File metadata and controls
36 lines (25 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from PIL import Image
## work images
def work_whit_images():
# Remember use try and except
try:
"""
open: Load image in memory
"""
image = Image.open('images/liger_zero_schneider.jpeg')
"""
convert: Convert images between different pixel representations “L”, “RGB” and “CMYK.”
"""
new_image = image.convert('L') # convert to gray scale
"""
show: Display image
"""
new_image.show()
"""
save: Save image
"""
new_image.save('images/liger_zero_schneider_gray.jpg')
except FileNotFoundError as error:
print('Image not found!')
if __name__ == '__main__':
work_whit_images()