安装Python Imaging Library记录

Posted 龙行天下之Sky

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装Python Imaging Library记录相关的知识,希望对你有一定的参考价值。

安装Python Imaging Library记录:
1、官网下载并解压到当前目录
wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
tar -xzvf Imaging-1.1.7.tar.gz
2、进入Imaging-1.1.7目录,修改setup.py文件中几个文件路径,每个人的路径不一定一样,这里需要注意一下,具体如下:
TCL_ROOT = "/usr/local/lib"
JPEG_ROOT = "/usr/local/lib"
ZLIB_ROOT = "/usr/local/lib"
TIFF_ROOT = "/usr/local/lib"
FREETYPE_ROOT = "/usr/local/lib"
LCMS_ROOT = "/usr/local/lib"

3、进行安装前的检查,没有问题进行安装:
python setup.py build_ext -i
检查没问题,可以执行安装了:
python setup.py install

安装过程会遇到很多问题,一般如下:
“fatal error: freetype/fterrors.h: No such file or directory”
解决方法:cd /usr/include
ln -s freetype2 freetype

“fatal error: Python.h: No such file or directory”
解决方法:$ sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev

有时需要建立链接,方便setup.py中路径的设置:
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

请参考:http://codeinthehole.com/tips/how-to-install-pil-on-64-bit-ubuntu-1204/

http://blog.csdn.net/five3/article/details/8625789

http://blog.csdn.net/lanfan_11/article/details/45558573


验证测试代码:
import Image  
picPath = '~/images/1212.jpg'  
 
im = Image.open(picPath)  
print im.getbbox()  
4、安装成功会显示:
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available

以上是关于安装Python Imaging Library记录的主要内容,如果未能解决你的问题,请参考以下文章

安装Python图型处理库Python Imaging Library(PIL)

Python之Python Imaging Library

Python Imaging Library---PIT

Python Imaging Library---PIT

Python Imaging Library---PIT

PIL(Python Imaging Library)图像处理库教程