Python之图片格式转换
2017-01-13 15:13
120 查看
import os import shutil from PIL import Image def getAllFiles(dirName, houzhui=' '): results = [] for file in os.listdir(dirName): file_path = os.path.join(dirName, file) if houzhui == ' ': if os.path.isfile(file_path): results.append([file_path, os.path.splitext(file)[0]]) else: if os.path.isfile(file_path) and os.path.splitext(file_path)[1] == houzhui: results.append([file_path,os.path.splitext(file)[0]]) return results def checkFile(fileName): if os.path.isfile(fileName): return True else: print fileName, 'is not found!' exit() def checkDir(fileName, creat=False): if os.path.isdir(fileName): if creat: shutil.rmtree(fileName) os.mkdir(fileName) else: if creat: os.mkdir(fileName) else: print fileName, 'is not found!' exit() if __name__ == '__main__': files = getAllFiles('./images/','.jpg') for file in files: fileName = file[0] fileShortName = file[1] saveFileName = './images/'+fileShortName+'.eps' Image.open(fileName).save(saveFileName)
相关文章推荐
- python实现批量图片格式转换
- python 将png图片格式转换生成gif动画
- 实际试验遇到的一些python问题,包括图片格式转换,python中调用linux命令行,用python画图等等。
- python 图片格式转换产生的锯齿问题
- 使用python进行图片格式转换
- Python调用“ImageMagick”:图片格式转换、尺寸修改、属性重构及加水印
- python---图片格式转换问题,NotImplementedError: tostring() has been removed.
- Python指南--使用Python解释器
- 跟老齐学Python之网站的结构
- Python指南--数据结构
- Python指南--数据结构
- 搭建Python的集成开发环境WingIDE
- Python指南--深入流程控制
- Python指南--深入流程控制
- 用Python实现数据库编程
- Python指南--开胃菜
- Python指南--开胃菜
- python3解析库lxml的安装与基本使用
- Python指南--初步认识Python
- Python指南--前言