批量修改图形文件的对比度和锐度,python 2.7
来源:互联网 发布:网络购物安全问题 编辑:程序博客网 时间:2024/04/30 14:01
import osimport Imageimport ImageEnhanceimport stringimport sys # process single file with factor , factor should be 2.0def procfile(filepath, destdir, factor): filedir, filename = os.path.split(filepath) if os.path.exists(os.path.join(destdir,filename)) == True: return im = Image.open(filepath) imContrast = ImageEnhance.Contrast(im).enhance(factor) imSharpness = ImageEnhance.Sharpness(imContrast).enhance(factor) if os.path.exists(destdir) != True : os.makedirs(destdir) imSharpness.save(os.path.join(destdir,filename)) def procfiles(filedir, targetdir, factor): print 'processing:' , filedir listdir = os.listdir(filedir) for pathname in listdir: print 'process file:', pathname entrypath = os.path.join(filedir, pathname) entrytarget = os.path.join(targetdir, pathname) if os.path.isdir(entrypath): procfiles(entrypath, entrytarget, factor) else: print pathname[-4:].upper() if pathname[-4:].upper() == '.JPG': print 'process:', pathname procfile(entrypath, targetdir, factor) procfiles(sys.argv[1], 'proc', 2.0)
写好保存成文件xxx.py,然后把要处理的文件夹拖放到xxx.py文件即可
目前还有碰到坏图片会停止过程的问题,有空再改吧,够用了
0 0
- 批量修改图形文件的对比度和锐度,python 2.7
- Python 图形处理库PIL批量修改图片大小和格式
- Python 图形处理库PIL批量修改图片大小和格式
- Python 图形处理库PIL批量修改图片大小和格式
- Python 批量修改文件
- python批量修改文件
- 使用python批量修改文件的后缀
- python 批量修改文件后缀
- python批量修改文件程序代码
- 批量修改cvs下面所有Root文件的python脚本
- Python批量修改文件夹里文件的名称
- 批量修改文件名和后缀名的python设计
- python实现批量修改文件扩展名
- Python 批量修改文件内关键字
- 批量修改文件的方法
- 批量修改文件的系统和隐藏属性
- Python学习08_图像的对比度和亮度
- mysql的批量新增和批量修改
- 【java】判断一个数是否为回文素数
- PhoneGap官网翻译 iOS开发常见问题文档
- 宽带ADSL猫指示灯含义及不亮问题解答
- java 10大常见异常
- tomcat 发布 webservice
- 批量修改图形文件的对比度和锐度,python 2.7
- 用alibaba的fastjson.jar把对象转化成json时避免$ref
- 中网在线PHP程序员面试经历(包含笔试题)
- 各种浏览器内核的区别
- kernel 编译错误 修改贴
- 伊斯兰自由大学:研究发现商店背景音乐不影响消费者行为
- 【java】打印部分日历
- javaJDBC(4)-事务、隔离级别
- 360随身wifi原理,功能特点,使用说明