#!/usr/bin/env python
#-*-coding:utf-8-*-
from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=800,height=600): *#预调整大小*
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('/home/dell/800-600/*.png'):*#原图像位置*
convertjpg(jpgfile,'/home/dell/800-600/') *#处理完保存位置*
python2.7 图像大小调整
最新推荐文章于 2022-12-15 15:28:22 发布