#提取目录下所有图片,更改尺寸后保存到另一目录
from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=128,height=128):
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:\\img\\*.jpg"):
convertjpg(jpgfile,"E:\\lianhua")
基于python实现图片批量修改分辨率
最新推荐文章于 2024-08-08 17:07:49 发布