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