Python一括修正画像サイズ

515 ワード

from PIL import Image
import os.path
import glob

def Resize(file, outdir, width, height):
    imgFile = Image.open(file)
    try:
        newImage = imgFile.resize((width, height), Image.BILINEAR)   
        newImage.save(os.path.join(outdir, os.path.basename(file)))
    except Exception as e:
        print(e)


for file in glob.glob("F:\\facereg\\image\\Tony_Blair\\*.jpg"):  #        
    Resize(file, "F:\\facereg\
image\\Tony_Blair", 224, 224) #