-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.py
26 lines (20 loc) · 843 Bytes
/
resize.py
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
from PIL import Image
directory = open('path.txt')
directory_path = directory.read()
def resize_image(input_image_path,
output_image_path,
size):
original_image = Image.open(input_image_path)
width, height = original_image.size
print('The original image size is {wide} wide x {height} '
'high'.format(wide=width, height=height))
resized_image = original_image.resize(size)
width, height = resized_image.size
print('The resized image size is {wide} wide x {height} '
'high'.format(wide=width, height=height))
resized_image.show()
resized_image.save(output_image_path)
if __name__ == '__main__':
resize_image(input_image_path=directory_path,
output_image_path=directory_path,
size=(28, 28))