1.安装依赖包
1.1 ubuntu安装
apt-get install python-dev
apt-get install libjpeg-dev apt-get install libjpeg8-dev apt-get install libpng3 apt-get install libfreetype6-dev ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib
或者
sudo apt-get build-dep python-imaging
由于ubuntu14中libfreetype 的头文件在/usr/include/freetype2目录下,但PIL中使用的路径是freetype,所以需要做以下操作
cd /usr/include ln -s freetype2 freetype
1.2 redhat/centos
yum install python-devel libjpeg-turbo-devel libpng-devel freetype-devel
2.安装PIL
最后使用pip安装PIL pip install PIL --allow-unverified PIL --allow-all-external
安装完成后可以看到如下版本信息,可以看到PNG中支持JPEG/PNG/ZIP/FREETYPE2
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.5 (default, Sep 15 2014, 17:30:20)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------