OpenCV:图像bmp格式转化为jpg格式

import os
from PIL import Image

# bmp 转换为jpg
def bmpToJpg(file_path):
    for fileName in os.listdir(file_path):
        # print(fileName)
        newFileName = fileName[0:fileName.find(".")] + ".jpg"
        print(newFileName)
        im = Image.open(file_path + "\\" + fileName)
        im.save(file_path + "\\" + newFileName)


# 删除原来的位图
def deleteImages(file_path, imageFormat):
    command = "del " + file_path + "\\*." + imageFormat
    os.system(command)


def main():
    file_path = "E:\\受电弓数据\\2019_09_19-20_24_19[3.3.0.1]{No1136}{5660204C-2CDC-4E55-B810-3B411B9EB3D9}(A-11009)B(1)\\2019_09_19-20_24_19[3.3.0.1]{No1136}{5660204C-2CDC-4E55-B810-3B411B9EB3D9}(A-11009)B\\bmp"
    bmpToJpg(file_path)
    # deleteImages(file_path, "bmp")


if __name__ == '__main__':
    main()

 

    原文作者:Robin Long 2018
    原文地址: https://blog.csdn.net/u013419318/article/details/102544525
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞