用python Pillow来批量缩放图片
用python Pillow来批量缩放图片

需求:比如有一组图片,尺寸大小不一,想缩放成相同的尺寸。

Pillow(Python Imaging Library)的安装

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow

一个使用pillow来缩放的例子

import os
from PIL import Image

files = os.listdir('.')

for file in files:
    if os.path.isfile(file) and file.endswith('.jpg') or file.endswith('.png'):
        im = Image.open(file)
        im_new = im.resize((300, 300))
        im_new.save('logo300_' + file)
感谢阅读,更多文章点击这里:【专栏:ExASIC】
公众号:ExASIC
分享数字集成电路设计中的经验和方法。分享让工作更轻松。
公众号二维码
留言(0)
还没有留言,来说两句吧。
留言需要 登录 或 注册(注册后需通过邮箱验证)。
相关文章