如下所示:
# coding:utf-8import osfrom PIL import Image# bmp 轉換為jpgdef 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+"http://"+fileName) im.save(file_path+"http://"+newFileName)# 刪除原來的位圖def deleteImages(file_path, imageFormat): command = "del "+file_path+"http://*."+imageFormat os.system(command)def main(): file_path = "D://VideoPhotos" bmpToJpg(file_path) deleteImages(file_path, "bmp")if __name__ == '__main__': main()
以上這篇python bmp轉換為jpg 并刪除原圖的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林站長站。
新聞熱點
疑難解答