from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=1280,height=720):
img=Image.open(jpgfile)
坦斗new_img=img.resize((width,height),Image.BILINEAR)
new_img.save(os.path.join(outdir,os.path.basename(jpgfile)))
for jpgfile in glob.glob("历信团D:/python/*.jpg"):
convertjpg(jpgfile,"D:/newfile")
convertjpg调用时可以有四个参数,如convertjpg(jpgfile,"D:/newfile",800,600)
Image open了jpg用完后要不要肢橘close?