Let your PHP support GIF, png, and JPEG at the same time_PHP tutorial

WBOY
Release: 2016-07-21 16:02:25
Original
1151 people have browsed it

Let your PHP support GIF, png, and JPEG at the same time

Compile and install according to the manual of php on RedHat6.2, and found that it can only process GIF images, not JPEG images. Later I learned that PHP uses the GD library to process images, and the GD library initially supported GIF. However, because GIF used the copyright-controversial LZW algorithm, it would cause legal problems, so starting from GD-1.6, the GD library no longer supports it. GIF, instead support the better, copyright-free PNG. And now I want to support GIF, PNG and JPEG at the same time.

1. Installation of Jpeg6b
RedHat6.2 already has the RPM package, so we don’t need to bother to compile it.
Insert the installation disk
mount /mnt/cdrom
cd /mnt/cdrom/RedHat/RPMS
rpm -ivh libjpeg*

Installation is successful, use rpm -ql libjpeg- 6b-10 Check and find that libjpeg.so.62.0.0 has been copied to the /usr/lib directory. Remember this directory, you will need it later when configuring php.

2. Installation of GD-1.8.3
The address to obtain the GD source code is:
http://www.boutell.com/gd/
Of course you can compile it yourself, but It does not support jpeg and needs to be patched.
The address to obtain the patch source code is:
http://www.webofsin.com/gd-1.8.3-gif.patch
The next step.........it will be very troublesome...I advise you It’s better not to compile it yourself! !

Why not use something already available? Someone has already patched it and compiled it into an RPM.
Available at:
http://rpms.arvin.dk/rh7-backports/gd/
http://rpms.arvin.dk/gd-with_gif/
Available. There are such good people in the world? ;-<
How touching! ! !

After downloading several gd-with_gif*.rpm, directly install rpm -ivh gd-with_gif*.
Use rpm -ql gd-with_gif-1.8.3-7 to check
and find that libgd.so.1.8.3 is placed under /usr/gd-with_gif/lib
Remember this directory when configuring PHP Use it too.

3. PHP installation and configuration
Since I heard that php4.0 does not support jpeg (I don’t know if I remember correctly), I recommend using the latest version of php.
Everyone should be familiar with the following, right?
So I copied the 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. Here is the key! ! !
./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars --with-jpeg-dir=/usr/lib --with-gd= /usr/gd-with_gif/lib
Of course, you can also add your own options, so I won’t go into details here.
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.)
------------------------- -------------

Finally succeeded, you can start apache and use phpinfo() to try it, and find gd:
------- ---------------
gd
GD Support enabled
GD Version 1.6.2 or higher
GIF Support enabled
PNG Support enabled
JPG Support enabled
WBMP Support enabled
----------------------

^_^Hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha ^
You can now use all PHP graphics functions:
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
……
Absolutely no problem! ! ! !

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316597.htmlTechArticleLet your PHP support GIF, png, and JPEG at the same time. Compile and install according to the manual of php on RedHat6.2, and found that only It can process GIF images, but cannot process JPEG images. Later I learned that PHP uses the GD library to process images,...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template