
GD庫預設是不支援JPEG格式圖檔處理的,若要增強GD庫的處理能力,使之能夠處理JPEG格式的圖檔,則需要在建構PHP的時候添加–with-jpeg-dir選項
1、安裝libjpeg
wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz
tar zxvf jpegsrc.v9b.tar.gz
cd jpeg-9b
./configure –prefix=/home/admin/app/jpeg –enable-shared –enable-static
make
make install
2、安裝php
wget http://cn2.php.net/distributions/php-5.6.27.tar.bz2
tar jxvf php-5.6.27.tar.bz2
cd php-5.6.27
./configure –with-jpeg-dir=/home/admin/app/jpeg –with-gd
make
make install
3、檢視GD庫是否已支援JPEG
(1) 使用phpinfo()函數,檢視gd子產品,如果有”JPEG Support”則表示GD庫已支援JPEG處理。
(2) 也可以使用在指令(php –re=gd | grep jpeg)檢視php的gd子產品是否支援JPEG:若指令執行結果中有imagecreatefromjpeg函數,則表示GD庫已支援JPEG處理。
參考:
GD庫安裝的需求:http://php.net/manual/en/image.requirements.php
GD庫的安裝方法:http://php.net/manual/en/image.installation.php