python批量图片像素大小和dpi

 用的是pillow

打开文件,遍历文件中的图像名字,修改访问地址。

修改图片。像是一个假的图片遍历,目前就这个水平啦。

run。

from PIL import Image
import os

files = os.listdir('./ori_img')
for item in files:
    item = "./ori_img/"+item
    print(item)
    img=Image.open(item)
    img.show()
    width, height = 358, 441
    img = img.resize((width, height))
    img.save(item,dpi = (300.0,300.0))

猜你喜欢

转载自blog.csdn.net/qq_46012097/article/details/127793966