PYTHON 批量修改图像旋转90度

import os
from PIL import Image

root = 'D:\image'
for filename in os.listdir(root):
    file_path = os.path.join(root, filename)
    PATH = 'D:\image1' + "/" + filename
    if os.path.splitext(file_path)[-1] == '.jpg':
        Img=Image.open(file_path)
        img=Img.rotate(90,expand=1)
        img.save(PATH)

root  输入图像路径

PATH  输出图像路径并保存图像

你可能感兴趣的:(python,java,python,开发语言)