-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_resize.py
More file actions
42 lines (29 loc) · 851 Bytes
/
04_resize.py
File metadata and controls
42 lines (29 loc) · 851 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
37
38
39
40
41
42
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')
"""
resize:
"""
width, height = image.size # obtain image size
# now go resize ten times
n_width = width // 10 # int
n_height = height // 10 # int
new_image = image.resize((n_width, n_height)) # new size for image
"""
show: Display image
"""
new_image.show()
"""
save: Save image
"""
new_image.save(f'images/liger_zero_schneider_{n_width}x{n_height}.jpg')
except FileNotFoundError as error:
print('Image not found!')
if __name__ == '__main__':
work_whit_images()