python批量修改图片分辨率
import cv2
import os
if __name__ == '__main__':
curDir = os.curdir # 获取当前执行python文件的文件夹
sourceDir = os.path.join(curDir, r"E:\Apple\test\image")
resultDir = os.path.join(curDir, r"E:\Apple\test\image1")
img_list = os.listdir(sourceDir)
for i in img_list:
pic = cv2.imread(os.path.join(sourceDir, i), cv2.IMREAD_COLOR)
pic_n = cv2.resize(pic, (256, 256))
pic_name = i
cv2.imwrite(os.path.join(resultDir, i), pic_n)
结果:
参考:
https://blog.csdn.net/watchful_guardian/article/details/102613803