PIL、Pillow安装使用方法
PIL(Python Imaging Library)是Python常用的图像处理库,而Pillow是PIL的一个友好Fork,提供了了广泛的文件格式支持,强大的图像处理能力,主要包括图像储存、图像显示、格式转换以及基本的图像处理操作等。
Pillow的文档:http://pillow.readthedocs.io/en/latest/
Pillow的github:https://github.com/python-pillow/Pillow
-----------------------------------------------------------------
0x0. Pillow的注意事项
Pillow and PIL cannot co-exist in the same environment. Before installing Pillow, please uninstall PIL.
Pillow >= 1.0 no longer supports “import Image”. Please use “from PIL import Image” instead.
Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead. Pillow < 2.0.0 supports Python versions 2.4, 2.5, 2.6, 2.7.
Pillow >= 2.0.0 < 4.0.0 supports Python versions 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
Pillow >= 4.0.0 supports Python versions 2.7, 3.3, 3.4, 3.5, 3.6
0x1. windows安装PIL
PIL安装很麻烦,推荐下载exe直接安装
PIL官网:http://pythonware.com/products/pil/
但现在里面下载链接访问不了,我把32位和64位版本上传到博客园以供下载。
PILwin32:http://files.cnblogs.com/files/pcat/PILwin32.zip
PILwin64:http://files.cnblogs.com/files/pcat/PILwin64.zip
0x2. windows安装Pillow
pip install Pillow
或者在http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow 下载wheel文件使用pip安装
0x3. linux安装python2.7、pip
sudo apt-get install python
sudo apt-get install python-pip
0x4. linux安装Pillow
在linux里安装PIL不怎么建议,依赖也多,而且会有各种报错。
kali的python默认已安装了Pillow。
在debian/ubuntu里安装Pillow:
sudo apt-get install python-imaging
或者
sudo pip install -I --no-cache-dir -v Pillow
python-imaging安装后的支持import Image
0x5. Pillow wrapper for PIL compatibility
github地址:https://github.com/yinpeng/pillow-pil
其作者是这样介绍:他项目中也使用Pillow替代了PIL,不过PIL和Pillow的import语句不兼容导致本项目代码修改倒还好说,问题是后来使用的依赖PIL的第三方组件不兼容,我们既不想同时安装Pillow和PIL,又不想修改第三方组件的源代码,所以他写了个很简单的Pillow-PIL,使得依赖PIL的第三方组件不用修改源代码就可以使用Pillow了。安装法子如下:
pip install Pillow-PIL
0x6. PIL一些报错
ImportError:The _imagingft C module is not installed
这个是在windows里安装PIL所报错,建议直接exe安装。
PIL.Image.open() IOError: cannot identify image file
首先检查图片是不是正确的,如果各种检查过还是有问题建议重装PIL
0x7. Pillow报KeyError问题
python
>>> import Image
>>> Image.init()
1
>>> Image.SAVE.keys()
['PCX', 'HDF5', 'EPS', 'MSP', 'XBM', 'WEBP', 'BUFR', 'PPM', 'BMP', 'TGA', 'ICO', 'TIFF', 'JPEG', 'SPIDER', 'GIF', 'GRIB', 'IM', 'FITS', 'PDF', 'WMF', 'MPO', 'PALM', 'JPEG2000', 'PNG']
如果Image.SAVE.keys()输出为空,则说明没有找到save format key,在生成图片时就会报KeyError, 此时就需要把import Image改成from PIL import Image
PIL、Pillow安装使用方法的更多相关文章
- python的PIL模块安装
一.Centos安装PIL #尤其重要,否则会报错 yum install python-devel yum install libjpeg libjpeg-devel zlib zlib-devel ...
- 安装Birt方法
安装BIRT 方法: 博客地址:http://www.mamicode.com/info-detail-850588.html 注意:在 Install new Software 中输入地址:http ...
- linux php安装扩展方法 查找配置文件
如何在linux中查看nginx.apache.php.mysql配置文件路径了,如果你接收一个别人配置过的环境,但没留下相关文档.这时该怎么判断找到正确的加载文件路径了.可以通过以下来判断 1.判断 ...
- node安装插件方法
node安装插件方法有几种,这里列出常用的两种方法: 方法1: 进入要安装插件的目录,直接用 npm 软件安装包安装,如(安装express): cd /project npm install -g ...
- windows server 2008见安装IIS方法(解决)
windows server 2008见安装IIS方法(解决) 刚开始有点蒙,后来才知道原来如此.! . 右键点击[我的电脑]--[管理]--[字符]--[加入角色]--仅落后win7像.啊! 版权声 ...
- elasticsearch+kibana+metricbeat安装部署方法
elasticsearch+kibana+metricbeat安装部署方法 本文是elasticsearch + kibana + metricbeat,没有涉及到logstash部分.通过beat收 ...
- RHEL6下获取安装包(RPM)而不安装的方法
RHEL6下获取安装包(RPM)而不安装的方法 有时候我们只能在某个机器上网获得RPM安装包,如何将RPM包在不能上网的内网机器安装,就需要能将安装包下载到本地而不安装,然后再把这些包复制到内网机器, ...
- 哈希长度扩展攻击(Hash Length Extension Attack)利用工具hexpand安装使用方法
去年我写了一篇哈希长度扩展攻击的简介以及HashPump安装使用方法,本来已经足够了,但HashPump还不是很完善的哈希长度扩展攻击,HashPump在使用的时候必须提供original_data, ...
- windows Sever 2012下Oracle 12c安装配置方法图文教程
windows Sever 2012下Oracle 12c安装配置方法图文教程 Oracle 12c安装配置方法图文教程,具体内容如下 1.我们开启虚拟机 2.Windows Sever 2012启动 ...
随机推荐
- Cartfile学习参考博客
1.http://www.cnblogs.com/xuruofan/p/6000864.html 2.http://www.jianshu.com/p/5ccde5f22a17
- vue 构建项目 文件引入
1.vue引用依赖文件. 举例:axios 先安装 axios.如果直接安装 vue-axios 会报错 npm install axios npm install --save axios vue ...
- java基础(一)---数据类型&Math方法&强制转换
数据类型及各种Math类方法 public class HelloWorld { public static void main(String args[]) { //各种数据类型的熟悉掌握,强制类型 ...
- zabbix监控tomcat(使用jmx监控,但不使用系统自带模版)
一,zabbx使用jmx监控tomcat的原理分析 1.Zabbix-Server找Zabbix-Java-Gateway获取Java数据 2.Zabbix-Java-Gateway找Java程序(j ...
- MyBatis笔记----SSM框架mybatis3整合springmvc spring4
上节 无springmvc框架 http://www.cnblogs.com/tk55/p/6661786.html 结构 jar包 web.xml 与index.jsp <?xml versi ...
- [20190312]关于增量检查点的疑问(补充).txt
[20190312]关于增量检查点的疑问(补充).txt --//有人问我以前写一个帖子的问题,关于增量检查点的问题,链接如下:http://blog.itpub.net/267265/viewspa ...
- C#方法重载(overload)方法重写(override)隐藏(new)
一.重载:同一个作用域内发生(比如一个类里面),定义一系列同名方法,但是方法的参数列表不同.这样才能通过传递不同的参数来决定到底调用哪一个. 值得注意的是,方法重载只有通过参数不同来判断调用哪个方法, ...
- IIS 使用OpenSSL 生成的自签名证书,然后使用SingalR 客户端访问Https 站点通信
使用SignalR 的客户端去发送消息给使用 https 部署的站点,官方文档目前并没有详细的教程,所以在此记录下步骤: 使用管理员身份打开cmd 窗口,选择一个整数保存文件夹的地址,切换到对应的文件 ...
- mysql 数据库安装
一.Mysql的安装 1. 安装mysql-server服务端 版本5.7.19-0ubuntu0.16.04.1 目前可以下载的版本: 5.5 5.6 5.7 8.0 测试版 输入:(我这里不需要客 ...
- 修改linux 默认SHELL
首先你得查看可以用的shell: 1.命令:chsh -l ,结果如下: /bin/sh/bin/bash/sbin/nologin/usr/bin/sh/usr/bin/bash/usr/sbin/ ...