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之图片格式转换的更多相关文章

  1. python 将png图片格式转换生成gif动画

    先看知乎上面的一个连接 用Python写过哪些[脑洞大开]的小工具? https://www.zhihu.com/question/33646570/answer/157806339 这个哥们通过爬气 ...

  2. 【VC++技术杂谈007】使用GDI+进行图片格式转换

    本文主要介绍如何使用GDI+对图片进行格式转换,可以转换的图片格式为bmp.jpg.png. 1.加载GDI+库 GDI+是GDI图形库的一个增强版本,提供了一系列Visual C++ API.为了使 ...

  3. bmp,jpg,png,tif,wmf,emf与eps图片格式转换

    wmf/emf是两种Microsoft Windows的图形文件格式.它是一个矢量图格式,但是也允许包含位图.本质上,一个WMF文件保存一系列可以用来重建图片的Windows GDI命令.在某种程度上 ...

  4. 利用PBFunc在Powerbuilder中进行图片格式转换

    利用PBFunc的n_pbfunc_image对象可以方便的进行图片格式的转换与大小转换 支持相互转换的格式有以下几种: FORMAT_BMP //bmp格式FORMAT_GIF  //gif格式FO ...

  5. php 图片格式转换-亲测ok

    代码如下 /** * 图片格式转换 * @param string $image_path 文件路径或url * @param string $to_ext 待转格式,支持png,gif,jpeg,w ...

  6. PIL图片格式转换

    PIL格式转换 原图: #!/usr/local/bin/python # -*- coding: utf8 -*- from PIL import Image, ImageFilter import ...

  7. 使用python将ppm格式转换成jpg【转】

    转自:http://blog.csdn.net/hitbeauty/article/details/48465017 最近有个很火的文章,叫 有没有一段代码,让你觉得人类的智慧也可以璀璨无比? 自己试 ...

  8. 图片格式转换之ImageMagick

    项目中需要实现一些图片文件到TIFF文件的转换,去网上下载了一些第三方软件. 好的软件需要收费,免费的存在各种问题. 自己动手,丰衣足食! 众里寻他千百度,蓦然回首,那人就是ImageMagick. ...

  9. MAC图片格式转换

    OS X下有一个sips的程序可以用来处理图片. sips的名称功能非常强大,参考 帮助文档 . 这里我们只用到其中的一个功能,转换图片格式. 命令参考: sips  - s format jpeg  ...

随机推荐

  1. flask的配置设置的几种方式

     Flask的配置对象(config)是一个字典(dict)的子类(subclass),所以你可以把配置用键值对的方式存储进去. 1.一些重要的配置,可以设置在系统环境变量里,又或者放到某个服务器里, ...

  2. CentOS7.x 通过mail命令发,使用465端口(smtps协议)发送邮件

    #创建证书mkdir -p /root/.certs/echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CE ...

  3. 一起來玩鳥 Starling Framework(4)TouchEvent,Touch,以及TouchPhase

    這一篇來介紹一下TouchEvent.我們先來談單點的touch,下一篇再介紹MultiTouch.翻過Starling文件的應該會發現,Starling裡面沒有MouseEvent,而是整合在Tou ...

  4. HTTP/2 Server Push 详解(上)

    收录待用,修改转载已取得腾讯云授权 译者:TAT.Johnny 原文:https://www.smashingmagazine.com/2017/04/guide-http2-server-push/ ...

  5. php中将SimpleXMLElement Object数组转化为普通数组

    做微信开发,鉴于微信POST的消息是XML数据包,通过SimpleXMLElement Object获取的数据不好操作,需要转化为普通数组. 网上找了很多方法都不理想,发现通过json_decode和 ...

  6. 我的mac OSX bash_profile文件

    A typical install of OS X won't create a .bash_profile for you. When you want to run functions from ...

  7. WPF动画制作简单的按钮动画

    主界面的代码 <StackPanel ButtonBase.Click="Grid_Click"> <Button Content="逐渐变大缩小&qu ...

  8. spring常用的一些注解以及注解注入总结

    常用的spring注解有如下几种: @Controller@Service@Autowired@RequestMapping@RequestParam@ModelAttribute@Cacheable ...

  9. object hook实现禁止创建文件

    object hook实现禁止创建文件 原理不说了,大伙都懂得.. 要解决的问题: ,FILE_NON_DIRECTORY_FILE); if (!NT_SUCCESS(status)) { dpri ...

  10. iOS即时通讯输入框随字数自适应高度

    代码地址如下:http://www.demodashi.com/demo/13210.html 前言 本人最近在研究socket与聊天界面的UI,在写聊天界面UI的时候是模仿微信的界面其中的文字输入框 ...