python bmp转换为jpg 并删除原图的方法

作者:sunfellow2009 时间:2023-03-12 02:48:50 

如下所示:


# coding:utf-8
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 = "D:\\VideoPhotos"
bmpToJpg(file_path)
deleteImages(file_path, "bmp")

if __name__ == '__main__':
main()

来源:https://blog.csdn.net/sunfellow2009/article/details/80742599

标签:python,bmp,jpg
0
投稿

猜你喜欢

  • Anaconda的安装与虚拟环境建立

    2022-05-26 01:06:22
  • Vue ElementUI在el-table中使用el-popover问题

    2024-05-09 15:22:15
  • Qt操作SQLite数据库的教程详解

    2024-01-16 14:10:04
  • Linux下C连接MySQL出现错误解决一例

    2008-12-29 13:17:00
  • 利用Python实现翻译HTML中的文本字符串

    2022-02-20 23:03:13
  • python3读取excel文件只提取某些行某些列的值方法

    2021-10-19 09:20:09
  • SQL Server 2008中的MERGE(不仅仅是合并)

    2010-10-15 14:16:00
  • python matplotlib库直方图绘制详解

    2023-01-19 06:38:34
  • go语言学习之包和变量详解

    2024-04-26 17:29:27
  • 详解express + mock让前后台并行开发

    2024-05-03 15:54:35
  • python中利用numpy.array()实现俩个数值列表的对应相加方法

    2022-08-26 01:49:25
  • 如何在Python中进行异常处理

    2021-02-21 06:51:01
  • linux配置mysql数据库远程连接失败的解决方法

    2024-01-28 06:53:59
  • 自然选择:自然界的颜色与界面设计[译]

    2009-09-19 17:17:00
  • 如何通过PHP实现Des加密算法代码实例

    2023-10-08 09:41:55
  • python中threading开启关闭线程操作

    2022-10-02 22:40:26
  • 解决Python spyder显示不全df列和行的问题

    2021-06-23 00:15:47
  • python写入已存在的excel数据实例

    2021-05-17 15:08:17
  • AJAX请求类下载

    2007-08-23 08:33:00
  • Python3逻辑运算符与成员运算符

    2021-03-29 18:59:14
  • asp之家 网络编程 m.aspxhome.com