Office 2013 / 2016 / 2019 ProPlus Retail零售版密钥上架

Python模块Pillow修改照片尺寸分辨率

Python

更新于:

0x00 概述

科学技术是第一生产力

0x01 开整

#conding=utf8
import os
from PIL import Image

def make_img(_path, _dpi, _width, _height):
    '''
    _dpi: (150,150)
    _width: 154
    _height: 189
    '''
    img0 = Image.open(_path)
    img1 = img0.resize((_width, _height), Image.ANTIALIAS)
    img1 = img1.convert('RGB')
    img1.save('{}_ok.jpg'.format(_path[:-4]), dpi=_dpi)

def find_img():
    _path = os.walk('./')
    for path, dir_list, file_list, in _path:
        for file_name in file_list:
            if __file__ == file_name:
                continue
            make_img(os.path.join(path, file_name), (150,150), 154, 189)
            # print(os.path.join(path, file_name))


def run():
    find_img()

if __name__ == '__main__':
    run()

0xff 完结撒花

转载请注明:【Python模块Pillow修改照片尺寸分辨率】https://jihuo.ma/python-pillow-modify-width-height-dpi.html

@楼主 昵称
评论