Allow your PHP to support GIF, PNG, and jpeg_php basics at the same time

Source: Internet
Author: User
Let your PHP support GIF, PNG, and JPEG at the same time

The RedHat6.2 is compiled and installed in PHP manual, and it is found that only GIF images can be processed and JPEG images cannot be processed. Later know that PHP processing images, using the GD library, and the GD library to support the beginning of GIF, but because GIF use of copyright controversial LZW algorithm, will cause legal problems, so from the GD-1.6, the GD library no longer support GIF, to support better, no copyright dispute png. And now I want to support both gif,png and JPEG.

1, the installation of jpeg6b
The RPM package is already in the RedHat6.2 and we don't have to bother compiling it.
Put in installation disk
Mount/mnt/cdrom
Cd/mnt/cdrom/redhat/rpms
RPM-IVH libjpeg*

Installation successful, with RPM-QL libjpeg-6b-10 view, found libjpeg.so.62.0.0 was copied to/usr/lib directory. Remember this directory and use it later with PHP.

2, the installation of GD-1.8.3
To obtain the GD source address is:
http://www.boutell.com/gd/
Of course you can compile it yourself, but it does not support JPEG, to be patched.
To obtain the patch source address is:
Http://www.webofsin.com/gd-1.8.3-gif.patch
Next.................. The trouble is dead ... Advise you still don't compile yourself!!

Why not use something that is ready-made? Someone has already patched up the patch and made it into RPM.
Can be in:
http://rpms.arvin.dk/rh7-backports/gd/
http://rpms.arvin.dk/gd-with_gif/
Get. There are such good people in this world?;-<
It's very moving!!!

Several gd-with_gif*.rpm are downloaded directly after RPM-IVH gd-with_gif* installation.
View with RPM-QL gd-with_gif-1.8.3-7
Found libgd.so.1.8.3 placed under/usr/gd-with_gif/lib.
Remember this directory and use it with PHP.

3, the installation and configuration of PHP
Since I've heard that php4.0 does not support JPEG (not to be mistaken), I recommend using the latest version of PHP.
The following, we should be familiar with not to be familiar with it?
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. This 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, this does not repeat.
9. Make
Make install
CD. /apache_1.3.x
For PHP 4:./configure--activate-module=src/modules/php4/libphp4.a
Make
Make install

Instead of this step you could prefer to simply copy the httpd binary
Overtop of your existing binary. Make sure your shut down your
Server-though.

CD. /php-x.x.x
For PHP 4:CP Php.ini-dist/usr/local/lib/php.ini

Can edit your. ini file to set PHP options. If
You are prefer this file in another location and use
--with-config-file-path=/path in step 8.

Edit your httpd.conf or srm.conf file and add:
for PHP 4:addtype application/x-httpd-php. php

Can choose any extension your wish here. . PHP is simply the one
We suggest. You can even include. html.


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 success, you can start Apache with Phpinfo () try to find GD there:
----------------------
Gd
GD Support Enabled
GD Version 1.6.2 or higher
GIF Support Enabled
PNG Support Enabled
JPG Support Enabled
WBMP Support Enabled
----------------------

^_^ hahaha haha ha ha ^_^
You can now use all of the 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!!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.