Make your PHP support GIF, PNG, and JPEG at the same time

Source: Internet
Author: User

Make your PHP support GIF, PNG, and JPEG at the same time

After redhat6.2 is compiled and installed by PHP manual, it is found that only GIF images can be processed and JPEG images cannot be processed. Later I learned that PHP used the GD library to process images, and the GD library started to support GIF. However, due to the use of the copyrighted LZWAlgorithm, Will cause legal issues, so from the beginning of the GD-1.6, GD library no longer support GIF, changed to support better, without copyright disputes PNG. Now I want to support both GIF, PNG and JPEG.

1. jpeg6b Installation
The RPM package already exists in redhat6.2, so we don't need to compile it.
Mount the disk
Mount/mnt/CDROM
CD/mnt/CDROM/RedHat/RPMS
Rpm-IVH libjpeg *

The installation was successful. Run the rpm-QL libjpeg-6b-10 to check and find that libjpeg. so.62.0.0 was copied to the/usr/lib directory. Remember this directory and use it later for PHP configuration.

2. GD-1.8.3 Installation
The address for getting GD source code is:
Http://www.boutell.com/gd/
Of course you can compile it by yourself, but it does not support JPEG and requires patching.
The address for obtaining the patch source code is:
Http://www.webofsin.com/gd-1.8.3-gif.patch
Next .................. So annoying ...... Advise you not to compile it yourself !!

Why don't we need something ready for use? Someone has already completed the patch compilation and made it an RPM.
You can:
Http://rpms.arvin.dk/rh7-backports/gd/
Http://rpms.arvin.dk/gd-with_gif/
. Is there such a good person in the world ?; -<
It's amazing !!!

Download several gd-with_gif *. rpm and install directly rpm-IVH gd-with_gif.
View with rpm-QL gd-with_gif-1.8.3-7
Found libgd. so.1.8.3 put under/usr/gd-with_gif/lib
Remember this directory and use it when configuring PHP.

3. install and configure PHP
I have heard that php4.0 does not support JPEG (I remember it wrong). I suggest using the latest PHP version.
Below, you should be familiar with it again?
So I copied the manual of PHP:
---------------------------------
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
You can also add your own options.
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
Use a HUP or usr1 signal .)
---------------------------------------

Finally, you can start Apache and try it with phpinfo () to 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
----------------------

^_^ Haha ^_^
Now you can use all the PHP graphic 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.