Answers for "change the size of images in a list in python"

2

change image resolution pillow

size = 7016, 4961
im = Image.open("my_image.png")
im_resized = im.resize(size, Image.ANTIALIAS)
im_resized.save("my_image_resized.png", "PNG")
Posted by: Guest on July-22-2020
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 "change the size of images in a list in python"

Python Answers by Framework

Browse Popular Code Answers by Language