工作中偶尔会用到图像批量选装,找工具有点麻烦,就查了一下python脚本。
双击一下就能完成的任务,为啥非要找工具呢,是吧。
#-*- coding: UTF-8 -*-from PIL import Image
import os# 获得文件夹下所有文件
filePath = './imgs/'
filenames = os.listdir(filePath)# 指定保存的文件夹
outputPath = './imgs_rotate/'# 迭代所有图片
for filename in filenames:# 读取图像im = Image.open(filePath + filename)# 指定逆时针旋转的角度im_rotate = im.transpose(Image.ROTATE_90)# im_rotate = im.transpose(Image.ROTATE_180)# im_rotate = im.transpose(Image.ROTATE_270)# 保存图像im_rotate.save(outputPath + filename)
参考:【python图像处理】图像的缩放、旋转与翻转