PIL、Pillow安装使用方法

来源:互联网 发布:什么软件可以打电话 编辑:程序博客网 时间:2024/05/22 16:57

PIL(Python Imaging Library)是Python常用的图像处理库,而Pillow是PIL的一个友好Fork,提供了了广泛的文件格式支持,强大的图像处理能力,主要包括图像储存、图像显示、格式转换以及基本的图像处理操作等。

Pillow的文档:http://pillow.readthedocs.io/en/latest/

Pillow的github:https://github.com/python-pillow/Pillow


0x1. windows安装PIL

PIL安装很麻烦,推荐下载exe直接安装

PIL官网:http://pythonware.com/products/pil/

但现在里面下载链接访问不了,我把32位和64位版本上传到博客资源以供下载。

PILwin32:http://download.csdn.net/download/th_num/10140028

PILwin64:http://download.csdn.net/download/th_num/10140029


0x2. windows安装Pillow

pip install Pillow
或者在http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow 下载wheel文件使用pip安装


0x3. 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

Pillow报KeyError问题
如果Image.SAVE.keys()输出为空,则说明没有找到save format key,在生成图片时就会报KeyError, 此时就需要把import Image改成from PIL import Image

原创粉丝点击