import cv2 import os image_size = 150 source_path = "test/" target_path = "test/" if not os.path.exists(target_path): os.makedirs(target_path) image_list = os.listdir(source_path) i = 0 for file in image_list: i = i + 1 image_source = cv2.imread(source_path + file) image = cv2.resize(image_source, (image_size, image_size), 0, 0, cv2.INTER_LINEAR) cv2.imwrite(target_path + ('0'+'_'+str(i)) + ".png", image) print("done")