python批量修改图片分辨率

from PIL import Image
import os.path
import glob


def convertjpg(jpgfile,outdir,width=640, height=640):
    img=Image.open(jpgfile)
    try:
        new_img=img.resize((width,height),Image.BILINEAR)
        new_img.save(os.path.join(outdir,os.path.basename(jpgfile)))
    except Exception as e:
        print(e)

for jpgfile in glob.glob("E:\\Aubo\\tomatoo\\*.jpg"):
    convertjpg(jpgfile, "E:\\Aubo\\tomatoo\\enhance")

你可能感兴趣的:(python)