python 压缩图片 到指定像素

# coding=utf-8
import glob
import os

from PIL import Image

# print(glob.glob(r'D:\VideoPhotos\sign\*.jpg'))
path = r 'D: \V ideoPhotos\sign'
images = glob.glob(path + r " \* .jpg")
for img in images:
# print(img)
im = Image.open(img)
# print(im.format, im.size, im.mode)
size = 1224, 1632
# print(size)
name = os.path.join(path, img)
im.thumbnail(size)
im.save(name, 'JPEG')
# print(im.format, im.size, im.mode)

猜你喜欢

转载自blog.csdn.net/sunfellow2009/article/details/80887476
今日推荐