Answers for "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"

0

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)
    #im.show()
    rotated_im = im.rotate(90)
    #rotated_im.show()
    resized_im = rotated_im.resize((128, 128))
    #resized_im.show()
    jpg_im = resized_im.convert("RGB")
    #jpg_im.show()
    jpg_im.save(fp=current_dir+dst+img[:-4]+'jpg', format='jpeg')
Posted by: Guest on November-26-2020

Code answers related to "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"

Python Answers by Framework

Browse Popular Code Answers by Language