Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make your PHP support both GIF and png and JPEG

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to make your PHP support GIF and png and JPEG at the same time. I think it's practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.

When RedHat6.2 is installed by php's manual compilation, it is found that only GIF images can be processed, not JPEG images. Later, we know that PHP processes images and uses the GD library, while the GD library supports GIF at the beginning, but because GIF uses the copyright disputed LZW algorithm, it will cause legal problems, so starting from GD-1.6, the GD library no longer supports GIF and instead supports better, non-copyright disputed PNG. The following editor will explain how to make your PHP support GIF, png and JPEG at the same time.

How to make your PHP support GIF, png and JPEG at the same time

1. Installation of Jpeg6b

Now that we have the RPM package in RedHat6.2, we don't have to bother to compile it.

Put in the installation disk

Mount/mnt/cdrom

Cd/mnt/cdrom/RedHat/RPMS

Rpm-ivhlibjpeg*

The installation is successful. Check with rpm-qllibjpeg-6b-10 and find that libjpeg.so.62.0.0 is copied to the / usr/lib directory. Remember this directory and use it later with 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 doesn't 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

Coming up... It's a lot of trouble. I advise you not to compile it yourself!

Why not use something ready-made? Someone has patched and compiled it into RPM.

It can be found in:

Http://rpms.arvin.dk/rh7-backports/gd/

Http://rpms.arvin.dk/gd-with_gif/

Get it. How can there be such a nice person in the world?;-< how touching! download a few gd-with_gif*.rpm and install it directly with rpm-ivhgd-with_gif*. Check with rpm-qlgd-with_gif-1.8.3-7 and find that libgd.so.1.8.3 is placed under / usr/gd-with_gif/lib. Remember this directory, and use it with php. How to make your PHP support GIF, png, JPEG 3, PHP installation and configuration at the same time since I have heard that php4.0 does not support jpeg (remember correctly), I suggest using the latest version of php. The following You should be too familiar with it, right? so I copied down php's manual:-- 1.gunzipapache_1.3.x.tar.gz 2.tarxvfapache_1.3.x.tar 3.gunzipphp-x.x.x.tar.gz 4.tarxvfphp-x.x.x .tar 5.cdapache_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, which will not be discussed in detail. 9.make 10.makeinstall 11.cd../apache_1.3.x 12.forPHP4:./configure--activate-module=src/modules/php4/libphp4.a 13.make 14.makeinstall Insteadofthisstepyoumayprefertosimplycopythehttpdbinary overtopofyourexistingbinary.Makesureyoushutdownyour serverfirstthough. 15.cd../php-x.x.x 16.forPHP4:cpphp.ini-dist/usr/local/lib/php.ini Youcanedityour.inifiletosetPHPoptions.If youpreferthisfileinanotherlocation,use-- with-config-file-path=/pathinstep8. 17.Edityourhttpd.conforsrm.conffileandadd: ForPHP4:AddTypeapplication/x-httpd-php.php Youcanchooseanyextensionyouwishhere..phpissimplytheone wesuggest.Youcaneveninclude.html. 18.UseyournormalprocedureforstartingtheApacheserver. (Youmust stopandrestarttheserver,notjustcausetheservertoreloadby useaHUPorUSR1signal.)-- finally succeeded. You can start apache and try it with phpinfo (). Find gd:-- gd GDSupportenabled GDVersion1.6.2orhigher GIFSupportenabled PNGSupportenabled JPGSupportenabled WBMPSupportenabled-- you can now use all the php graphics functions: ImageCreateFromGIF ()-CreateanewimagefromfileorURL ImageCreateFromJPEG ()-CreateanewimagefromfileorURL ImageCreateFromPNG ()-CreateanewimagefromfileorURL... The above is

The above is how to make your PHP support both GIF and png and JPEG. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report