from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=256,height=256):
img=Image.open(jpgfile)
h, w = img.size
if h != 256 or w != 256:
try:
print(jpgfile,h,w)
new_img=img.resize((width,height),Image.NEAREST) #ANTIALIAS
new_img.save(os.path.join(outdir,os.path.basename(jpgfile)))
except Exception as e:
print(e)
for jpgfile in glob.glob("./9-crack776/mask-yuan/*"):
convertjpg(jpgfile,"./9-crack776/mask")
python更改图像尺寸resize
最新推荐文章于 2024-04-16 14:39:29 发布