import os
from PIL import Image
classes={'藏','川','鄂','甘','赣','贵','桂','黑','沪','吉','冀','津','晋','京','辽','鲁','蒙','闽','宁','青','琼',
'陕','苏','皖','湘','新','渝','豫','粤','云','浙'}
def bmpToJpg(file_path):
for fileName in os.listdir(file_path):
print(fileName)
newFileName = fileName[0:fileName.find(".bmp")]+".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 = "F:\pycharm\charSamples\train\training-set\"
for index,name in enumerate(classes):
path=file_path+name
bmpToJpg(path)
deleteImages(path, "bmp")
if __name__ == '__main__':
main()
最后
以上就是现代石头最近收集整理的关于python bmp转jpg的全部内容,更多相关python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复