
from PIL import Image
import os.path
import glob
import cv2
def convertjpg(jpgfile,outdir,width=480,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("图片储存路径/*.jpg"):
convertjpg(jpgfile, "修改后图片保存路径")