PIL是python理想的圖片處理module,但是想要良好的支持各種圖片,還需要檢查一下幾步,否則會提示:IOError: decoder jpeg not available之類的。
我的環境:Linux ubuntu 13.10 amd64 / Python3.3.2+
第一步:安裝zlib png freetype jpeg
- install zlib (ubuntu 官方源沒有zlib,別想apt-get了)
下載zlib,(zlib.net已牆,可以去SF.net),url: http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download?use_mirror=superb-dca2
shell:
$ cd zlib-1.2.5
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
- install png(忘記apt-get吧)
$ tar -xvzf libpng-1.6.7.tar.gz
$ cd libpng-1.6.7.tar.gz
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
- install freetype (忘記apt-get吧)
shell:
$ tar -xvzf freetype-2.4.7.tar.gz
$ cd freetype-2.4.7/
$ ./configure --prefix=/usr/local
$ make
$ make install
- install jpeg (忘記apt-get吧)
shell:
$ tar -xvzf jpegsrc.v8c.tar.gz
$ cd jpeg-8c/
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
第二步:安裝需要的 devel庫(現在是想起apt-get的時候了)
$ sudo apt-get install libpng12-dev
$ sudo apt-get install libfreetype6-dev
$ sudo apt-get install zlib1g-dev
第三步:安裝 PIL( Python Imaging Library )
獲得資源:url: https://github.com/python-imaging/Pillow下載後將其解壓縮在任一文件夾中,進入目錄
$ python3 setup.py build_ext -i
running build_ext
--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.2.1
platform linux 3.3.2+ (default, Oct 9 2013, 14:50:09)
[GCC 4.8.1]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- TIFF G3/G4 (experimental) support available
--- FREETYPE2 support available
--- LITTLECMS2 support available
--- WEBP support available
*** WEBPMUX support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
正式安裝: