Python OpenCV读取png图像转成jpg图像存储的方法

时间:2022-02-07 14:55:05

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
import cv2
import sys
import numpy as np
 
path = "F:\\ImageLib\\VRWorks_360_Video _SDK_1.1\\footage14\\"
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)

以上这篇Python OpenCV读取png图像转成jpg图像存储的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/bevison/article/details/79126410