大家可以任意更换
import os
import cv2
import sys
import numpy as np
path = "./image/"
OldFormat = ".jpg"
NewFormat = ".png"
for filename in os.listdir(path):
if os.path.splitext(filename)[1] == OldFormat:
img = cv2.imread(path + filename)
print(filename.replace(OldFormat, NewFormat))
newfilename = filename.replace(OldFormat, NewFormat)
cv2.imwrite(path + newfilename, img)
网友评论