python resize all images in folder code example
Example: This is the challenge section of the lab where you'll write a script that uses PIL to perform the following operations: Iterate through each file in the folder
import os
from PIL import Image
path = "\\images\\"
dst = "\\opt\\icons\\"
current_dir = os.getcwd()
images = os.listdir(current_dir+path)
print(images)
for img in images:
im = Image.open(current_dir+path+img)
rotated_im = im.rotate(90)
resized_im = rotated_im.resize((128, 128))
jpg_im = resized_im.convert("RGB")
jpg_im.save(fp=current_dir+dst+img[:-4]+'jpg', format='jpeg')