我的知识记录

Python 批量改图片尺寸

import os
from PIL import Image

folder = './图片'
size = (800, 800)  # 目标尺寸
for f in os.listdir(folder):
    if f.lower().endswith(('.jpg', '.jpeg', '.png')):
        img = Image.open(os.path.join(folder, f))
        img.thumbnail(size)  # 等比缩放
        img.save(os.path.join(folder, 's_' + f))
print("缩放完成")

Python 批量改图片尺寸

标签:

更新时间:2026-09-14 13:14:01

上一篇:Python PDF 合并 / 拆分

下一篇:Python定时提醒 / 番茄钟