在RedHat6.2按php的manual編譯安裝,發現只能處理GIF圖像,不能處理JPEG圖像。后來知道PHP處理圖像,使用了GD庫,而GD庫開始時是支持GIF的,但由于GIF使用了有版權爭議的LZW算法,會引起法律 " /> 一区二区三区日韩欧美精品,欧美激情成人动漫,国产精品成人一区二区不卡

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

讓你的PHP同時支持GIF、png、JPEG

讓你的php同時支持GIF、png、JPEG

在RedHat6.2按php的manual編譯安裝,發現只能處理GIF圖像,不能處理JPEG圖像。后來知道php處理圖像,使用了GD庫,而GD庫開始時是支持GIF的,但由于GIF使用了有版權爭議的LZW算法,會引起法律問題,于是從GD-1.6開始,GD庫不再支持GIF,改為支持更好的,無版權爭議的PNG。而我現在希望同時支持GIF,PNG和JPEG。

1、 Jpeg6b的安裝
RedHat6.2中已經有了RPM包,我們也就不需要去費勁編譯了。
  放入安裝盤
  mount /mnt/cdrom
  cd /mnt/cdrom/RedHat/RPMS
  rpm -ivh libjpeg*

安裝成功,用rpm -ql libjpeg-6b-10 查看,發現libjpeg.so.62.0.0被拷到/usr/lib目錄下。記住此目錄,等會兒配php時要用。

2、 GD-1.8.3的安裝
獲取GD源碼的地址為:
http://www.boutell.com/gd/
你當然可以自己編譯,但它不支持jpeg,要打補丁。
獲取補丁源碼的地址為:
http://www.webofsin.com/gd-1.8.3-gif.patch
接下來………………麻煩死了……勸你還是不要自己編譯了!!

有現成的東西為何不用呢?已經有人打好補丁編譯好了,做成RPM。
可以在:
http://rpms.arvin.dk/rh7-backports/gd/
http://rpms.arvin.dk/gd-with_gif/
得到。世上竟然有這么好的人?;-<
真令人感動!!!

下載了幾個gd-with_gif*.rpm后直接 rpm -ivh gd-with_gif* 安裝。
用 rpm -ql gd-with_gif-1.8.3-7 查看
發現 libgd.so.1.8.3 放到了 /usr/gd-with_gif/lib 下
記住此目錄,配php時也要用。

3、 php的安裝和配置
鑒于曾聽說php4.0不支持jpeg(不知記錯沒),我建議還是用php的最新版。
下面的,大家應該熟悉得不能再熟悉了吧?
于是我把php的manual抄下來:
---------------------------------
1. gunzip apache_1.3.x.tar.gz
2. tar xvf apache_1.3.x.tar
3. gunzip php-x.x.x.tar.gz
4. tar xvf php-x.x.x.tar
5. cd apache_1.3.x
6. ./configure --prefix=/www
7. cd ../php-x.x.x
8. 這里是關鍵!!!
  ./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars --with-jpeg-dir=/usr/lib --with-gd=/usr/gd-with_gif/lib
  當然你也可以加上你自己的選項,此不贅述。
9. make
10. make install
11. cd ../apache_1.3.x
12. for php 4: ./configure --activate-module=src/modules/php4/libphp4.a
13. make
14. make install

Instead of this step you may prefer to simply copy the httpd binary
overtop of your existing binary. Make sure you shut down your
server first though.

15. cd ../php-x.x.x
16. for php 4: cp php.ini-dist /usr/local/lib/php.ini

You can edit your .ini file to set php options. If
you prefer this file in another location, use
--with-config-file-path=/path in step 8.

17. Edit your httpd.conf or srm.conf file and add:
   For php 4:  AddType application/x-httpd-php .php

You can choose any extension you wish here. .php is simply the one
we suggest. You can even include .html .


18. Use your normal procedure for starting the Apache server. (You must
  stop and restart the server, not just cause the server to reload by
  use a HUP or USR1 signal.)
---------------------------------------

終于成功了,你可以啟動apache用phpinfo()試一試,發現gd那里:
----------------------
    gd
GD Support enabled
GD Version 1.6.2 or higher
GIF Support enabled
PNG Support enabled
JPG Support enabled
WBMP Support enabled
----------------------

^_^哈哈哈哈哈哈哈哈哈^_^
你現在可以用到所有的php圖形函數了:
ImageCreateFromGIF() ― Create a new image from file or URL
ImageCreateFromJPEG() ― Create a new image from file or URL
ImageCreateFromPNG() ― Create a new image from file or URL
……
絕對沒問題!!!!

php技術讓你的PHP同時支持GIF、png、JPEG,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 岳西县| 西充县| 阿克陶县| 鹤庆县| 正阳县| 宁海县| 松阳县| 岱山县| 永川市| 汉寿县| 泸水县| 高密市| 咸丰县| 北流市| 合作市| 黑山县| 建湖县| 台北县| 徐州市| 大名县| 济宁市| 陵川县| 普洱| 谢通门县| 古丈县| 宁德市| 上虞市| 宁蒗| 安丘市| 会东县| 辽源市| 海丰县| 凤翔县| 方正县| 柘荣县| 济源市| 贡山| 洛扎县| 澄江县| 安岳县| 正安县|