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


Posted in Python onOctober 25, 2018

如下所示:

# 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()

以上这篇python bmp转换为jpg 并删除原图的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
web.py在SAE中的Session问题解决方法(使用mysql存储)
Jun 24 Python
在Django中限制已登录用户的访问的方法
Jul 23 Python
利用pandas将numpy数组导出生成excel的实例
Jun 14 Python
Django实战之用户认证(用户登录与注销)
Jul 16 Python
python 中文件输入输出及os模块对文件系统的操作方法
Aug 27 Python
python对日志进行处理的实例代码
Oct 06 Python
python利用插值法对折线进行平滑曲线处理
Dec 25 Python
Python列表与元组的异同详解
Jul 02 Python
django 取消csrf限制的实例
Mar 13 Python
python 实现图片修复(可用于去水印)
Nov 19 Python
基于注解实现 SpringBoot 接口防刷的方法
Mar 02 Python
Pytest实现setup和teardown的详细使用详解
Apr 17 Python
virtualenv 指定 python 解释器的版本方法
Oct 25 #Python
解决python3读取Python2存储的pickle文件问题
Oct 25 #Python
python 解压pkl文件的方法
Oct 25 #Python
纯用NumPy实现神经网络的示例代码
Oct 24 #Python
Django添加KindEditor富文本编辑器的使用
Oct 24 #Python
Django使用paginator插件实现翻页功能的实例
Oct 24 #Python
Python将8位的图片转为24位的图片实现方法
Oct 24 #Python
You might like
php whois查询API制作方法
2011/06/23 PHP
ThinkPHP中自定义错误页面和提示页面实例
2014/11/22 PHP
WordPress过滤垃圾评论的几种主要方法小结
2016/07/11 PHP
如何让动态插入的javascript脚本代码跑起来。
2007/01/09 Javascript
javascript实现十六进制颜色值(HEX)和RGB格式相互转换
2014/06/20 Javascript
javascript实现获取浏览器版本、操作系统类型
2015/01/29 Javascript
jQuery中通过ajax调用webservice传递数组参数的问题实例详解
2016/05/20 Javascript
AngularJS  $on、$emit和$broadcast的使用
2016/09/05 Javascript
javascript实现根据汉字获取简拼
2016/09/25 Javascript
Angular4表单验证代码详解
2017/09/03 Javascript
浅谈ElementUI中switch回调函数change的参数问题
2018/08/24 Javascript
Vue项目查看当前使用的elementUI版本的方法
2018/09/27 Javascript
VSCode 添加自定义注释的方法(附带红色警戒经典注释风格)
2020/08/27 Javascript
如何运行Python程序的方法
2013/04/21 Python
深入理解Python中的super()方法
2017/11/20 Python
python版学生管理系统
2018/01/10 Python
Tensorflow实现卷积神经网络的详细代码
2018/05/24 Python
python批量修改文件编码格式的方法
2018/05/31 Python
python+opencv 读取文件夹下的所有图像并批量保存ROI的方法
2019/01/10 Python
python读取并定位excel数据坐标系详解
2019/06/26 Python
python处理大日志文件
2019/07/23 Python
python实现多进程按序号批量修改文件名的方法示例
2019/12/30 Python
Python利用 utf-8-sig 编码格式解决写入 csv 文件乱码问题
2020/02/21 Python
python 错误处理 assert详解
2020/04/20 Python
利用python控制Autocad:pyautocad方式
2020/06/01 Python
Python接口自动化测试框架运行原理及流程
2020/11/30 Python
Python排序函数的使用方法详解
2020/12/11 Python
WatchShop法国:英国排名第一的独立手表零售商
2020/02/17 全球购物
Java工程师面试集锦之Spring框架
2013/06/16 面试题
大学生毕业自我鉴定范文
2013/09/19 职场文书
网络营销策划方案
2014/06/04 职场文书
大学生实训报告总结
2014/11/05 职场文书
婚礼女方父母答谢词
2015/01/04 职场文书
毕业典礼邀请函
2015/01/31 职场文书
警告通知
2015/04/25 职场文书
2016春季运动会通讯稿
2015/07/18 职场文书