import cv2
import os
a = 'reselect-bmx-all'
path = './images/%s' % a
files = os.listdir(path)
if not os.path.exists('./images/resize-%s' % a):
os.makedirs('./images/resize-%s' % a)
for file in files:
# print(path + '/' + file)
img = cv2.imread(path + '/' + file)
x = img.shape[1]
y = img.shape[0]
if x == 480 and y == 270:
cv2.imwrite('./images/resize-%s/' % a + file[:-4] + '.png', img)
else:
img = cv2.resize(img, (480, 270))
cv2.imwrite('./images/resize-%s/' % a + file[:-4] + '.png', img)
print(file[:-4] + '.png' + ' have been resize!')
批量修改图像大小
最新推荐文章于 2024-04-29 20:52:08 发布