本文根据实际情况做过修改
import os
import time
import cv2
def alter(path,out):
s = os.listdir(path)
for i in s:
document = os.path.join(path,i)
img = cv2.imread(document)
img = cv2.resize(img, (400,300))
fileName=i.split(".JPG")
cv2.imwrite(out+'%s.jpg' % fileName[0], img)
alter('e:\\orig','e:\\res\\')
源文件在e:\\orig,目标文件在e:\\res\\,转换后的图片大小为 400x300