ubuntu安裝圖像處理庫PIL

PIL(Python Image Library)圖像處理庫,是python中最常用的圖像處理庫,目前的版本是1.17。該庫提供了基本的圖像處理功能,例如改變圖像改變大小、格式轉換、色場空間轉換、圖像增強、直方圖處理、生成二維碼、插值和濾波等。

在安裝PIL之前,需要安裝依賴庫:zlib, png, freetype, jpeg

依賴運行庫的安裝:這個庫是不能用 apt-get安裝的,因此需要自己編譯安裝

安裝依賴庫:zlib
$:wget https://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz
$:tar -zxvf zlib-1.2.8.tar.gz
$:./configure --prefix=/usr/local/lib
$:cd zlib-1.2.8
$:make
$:sudo make install 

安裝依賴庫:png
$:wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.21.tar.gz
$:tar -zxvf libpng-1.6.21.tar.gz
$:./configure --prefix=/usr/local/lib
$:cd libpng-1.6.21
$:make
$:sudo make install

安裝依賴庫:freetype
$:wget https://sourceforge.net/projects/freetype/files/freetype2/2.6.3/freetype-2.6.3.tar.gz
$:tar -zxvf freetype-2.6.3.tar-gz
$:./configure --prefix=/usr/local/lib
$:cd freetype-2.6.3
$:make
$:sudo make install

安裝依賴庫:jpeg
$:wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
$:tar -zxvf jpegsrc.v8c.tar.gz
$:cd jpeg-8c
$:./configure --prefix=/usr/local/lib
$:make
$:sudo make install

安裝dev鏈接庫

sudo apt-get install zlib1g-dev libpng12-dev libfreetype6-dev libjpeg8-dev

安裝PIL庫

$:wget wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$:tar -zxvf Imaging-1.1.7
$:cd Imageing-1.1.7

修改setup.py
JPEG_ROOT = "/usr/local/lib"
ZLIB_ROOT = "/usr/local/lib"
FREETYPE_ROOT = "/usr/local/lib"

檢查系統環境是否配置成功:
$:cd Imaging-1.1.7
$:python setup.py build_ext -i
running build_ext
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.6 (default, Jun 22 2015, 17:58:13)
              [GCC 4.8.2]
--------------------------------------------------------------------
*** TKINTER support not available (Tcl/Tk 8.6 libraries needed)
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS 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.
只要JPEG、ZLIB、FREETYPE2 是 available就行

開始PIL的安裝:
$:python setup.py build
(我出現的錯誤 <freetype/freetype> 不存在,處理方法:cd /usr/include  sudo ln -s freetype2 freetype)
$:python setup.py install

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章