from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=600,height=400):
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:\gaodan\1\pytorch_segmentation-master\testImages\ge\*.jpg”):
convertjpg(jpgfile,“E:\gaodan\1\pytorch_segmentation-master\testImages\ge1\”)
print(“完成”)
转载自:
版权声明:本文为CSDN博主「暗夜精灵宝宝」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43196262/article/details/82807333