Python之图片格式转换
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写过哪些[脑洞大开]的小工具? https://www.zhihu.com/question/33646570/answer/157806339 这个哥们通过爬气 ...
- 【VC++技术杂谈007】使用GDI+进行图片格式转换
本文主要介绍如何使用GDI+对图片进行格式转换,可以转换的图片格式为bmp.jpg.png. 1.加载GDI+库 GDI+是GDI图形库的一个增强版本,提供了一系列Visual C++ API.为了使 ...
- bmp,jpg,png,tif,wmf,emf与eps图片格式转换
wmf/emf是两种Microsoft Windows的图形文件格式.它是一个矢量图格式,但是也允许包含位图.本质上,一个WMF文件保存一系列可以用来重建图片的Windows GDI命令.在某种程度上 ...
- 利用PBFunc在Powerbuilder中进行图片格式转换
利用PBFunc的n_pbfunc_image对象可以方便的进行图片格式的转换与大小转换 支持相互转换的格式有以下几种: FORMAT_BMP //bmp格式FORMAT_GIF //gif格式FO ...
- php 图片格式转换-亲测ok
代码如下 /** * 图片格式转换 * @param string $image_path 文件路径或url * @param string $to_ext 待转格式,支持png,gif,jpeg,w ...
- PIL图片格式转换
PIL格式转换 原图: #!/usr/local/bin/python # -*- coding: utf8 -*- from PIL import Image, ImageFilter import ...
- 使用python将ppm格式转换成jpg【转】
转自:http://blog.csdn.net/hitbeauty/article/details/48465017 最近有个很火的文章,叫 有没有一段代码,让你觉得人类的智慧也可以璀璨无比? 自己试 ...
- 图片格式转换之ImageMagick
项目中需要实现一些图片文件到TIFF文件的转换,去网上下载了一些第三方软件. 好的软件需要收费,免费的存在各种问题. 自己动手,丰衣足食! 众里寻他千百度,蓦然回首,那人就是ImageMagick. ...
- MAC图片格式转换
OS X下有一个sips的程序可以用来处理图片. sips的名称功能非常强大,参考 帮助文档 . 这里我们只用到其中的一个功能,转换图片格式. 命令参考: sips - s format jpeg ...
随机推荐
- 你真的了解try{ return }finally{}中的return?(转载)
发现一篇有意思的博文,分享一下 谁能给我我解释一下这段程序的结果为什么是:2.而不是:3 代码如下: class Test { public int aaa() { int x = 1; try { ...
- redis基本命令,配置参数
https://www.w3cschool.cn/redis/redis-pub-sub.html redis-server --maxclients 100000 客户端命令CLIENT LIST ...
- iOS: ios视频播放(MPMediaPlayerController,AVPlayer,AVPlayerViewcontroller、ffmpeg-AVPlayer)
介绍: 和音频播放一样,ios也提供个很多的API.如mediaPlayer.framework下的MPMediaPlayerController.AVFounditon.framework下的AVP ...
- Arduino+GPRS 的环境监控方案
设备前台界面:http://www.lewei50.com/home/gatewaystatus/361#576 本实采用的硬件,除了一个串口模块以外(约200元),其他均可以从taobo上面找到标准 ...
- javascript快速入门23--XHR—XMLHttpRequest对象
创建XMLHttpRequest对象 与之前众多DOM操作一样,创建XHR对象也具有兼容性问题:IE6及之前的版本使用ActiveXObject,IE7之后及其它浏览器使用XMLHttpRequest ...
- HTC VIVE SDK 中的例子 hellovr_opengl 程序流程分析
最近Vive的VR头盔设备很火,恰逢项目需求,所以对 SDK 中的例子 hellovr_opengl 做了比较细致的代码分析,先将流程图绘制如下,便于大家理解. 在ViVe头盔中实现立体效果的技术核心 ...
- Bitnami 2015
WordPress WordPress is one of the world's most popular web publishing platforms for building blogs a ...
- 【IE兼容性】background:transparent IE中Bug,不能选中input输入框,出现这个问题主要是IE8
先解释下,background:transparent,默认在IE上会被解析成 background: none transparent scroll repeat 0% 0% transparent ...
- 大话项目管理工具之Jira篇
前言 上一篇文章谈的是知识管理工具 -- Confluence,它来自澳大利亚 Atlassian 公司. 非常凑巧的是,今天要介绍的 JIRA 也是来自 Atlassian 公司的.但他不再是知识管 ...
- SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) 这个 ...