python 照片更改尺寸

from PIL import Image
import os.path
import glob
def convertjpg(jpgfile,outdir,width=150,height=200):
    img=Image.open(jpgfile)
    try:
        new_img = img.resize((width, height), Image.BILINEAR)
        if new_img.mode == 'P':
            new_img = new_img.convert("RGB")
        if new_img.mode == 'RGBA':
            new_img = new_img.convert("RGB")
        new_img.save(os.path.join(outdir, os.path.basename(jpgfile)))
    except Exception as e:
        print(e)

for jpgfile in glob.glob("C:/Users/app/Pictures/in/me.jpg"):
    # print(jpgfile)
    convertjpg(jpgfile,"C:/Users/app/in/out")
上一篇:In file included from adlist.c:34:0: zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录


下一篇:你所不知道的html5与html中的那些事(四)——文本标签