图片格式转换

py实现图片格式的转换:

import os
import cv2
import sys
import numpy as np

path = "G://leide//zhuan//"
print(path)

for filename in os.listdir(path):
    if os.path.splitext(filename)[1] == '.png':
        # print(filename)
        img = cv2.imread(path + filename)
        print(filename.replace(".png", ".jpg"))
        newfilename = filename.replace(".png", ".jpg")
        # cv2.imshow("Image",img)
        # cv2.waitKey(0)
        cv2.imwrite(path + newfilename, img)
发布了6 篇原创文章 · 获赞 4 · 访问量 89

猜你喜欢

转载自blog.csdn.net/Fighting_y/article/details/104900092