图像处理python(三)PIL读取图像以及尺寸调整保存

 图像尺寸调整以及保存:

import os
from PIL import Image
 
filename = os.listdir("./train/main/label1/")
base_dir = "./train/main/label1/"
new_dir  = "./train/main/label/"
size_m = 800
size_n = 640
 
for img in filename:
    image = Image.open(base_dir + img)
    image_size = image.resize((size_m, size_n),Image.ANTIALIAS)
    image_size.save(new_dir+ img)

 

你可能感兴趣的:(Python,图像处理)