https://www.2cto.com/kf/201603/492898.html
需要支持pip,然后安装:pip install Pillow
#coding:gbk
'''pip install Pillow'''
import os
from PIL import Image,ImageDraw,ImageFont
img=os.path.join('E:\\[[cache]]','test.jpg')
re_img=img.split('\\')[-1].split('.')[0]
im = Image.open(img)
im = im.convert('1')#9种压缩模式:1/L灰度/P/RGB/RGBA/CMYK/YCbCr/I/F
im.save(u're_%s.jpg'%(re_img), optimize=True)
网友评论