Python 批量調整圖片大小

from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=576,height=384):
    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:\\新建文件夾\\png\\*.png"):
    convertjpg(jpgfile,"E:\\新建文件夾\\png\\1")
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章