如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import os from PIL import Image filename = os.listdir( "D:\\Work\\process\\样本处理\\polyu-all-train" ) base_dir = "D:\\Work\\process\\样本处理\\polyu-all-train\\" new_dir = "D:\\Work\\process\\样本处理\\polyu\\" size_m = 128 size_n = 128 for img in filename: image = Image. open (base_dir + img) image_size = image.resize((size_m, size_n),Image.ANTIALIAS) image_size.save(new_dir + img) |
以上这篇python批量修改图片尺寸,并保存指定路径的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qq_38640439/article/details/81664919