-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
28 lines (23 loc) · 831 Bytes
/
main.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
27
28
# Import the modules needed
from PIL import Image
import os
# Folder Path
# replace this path with the path to your folder containing the images
path = "/Users/jovan/Desktop/images/"
# Getting list of image paths (path to each image in the folder)
image_path = os.listdir(path)
images = []
for x in image_path:
images.append(path + x)
# Loop for each image
for x in images:
# loophole to not allow .DS_Store files to pass on macOS
if x != '/Users/jovan/Desktop/images/.DS_Store':
# set the base width you want
basewidth = 1920
img = Image.open(x)
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.LANCZOS)
img.save(x)
print('The images have been succesfully resized.')