You are viewing a single comment's thread from:

RE: 每天进步一点点:使用Python批量修改图片尺寸

补充一下使用Pillow库来改变图像尺寸的核心内容

from PIL import Image

def resize_image_by_pillow(file_path, scale_percent):
    img = Image.open(file_path)
    width = int(img.size[0] * scale_percent / 100)
    height = int(img.size[1] * scale_percent / 100)
    resized_img = img.resize((width, height))
    resized_img.save(file_path)

正文主函数中替换函数名即可