PHP4 and JPEG How To (was Re: GD 1.8.1/PHP RC1)
| From: | Flavien LEBARBE | Date: | Wed, 19 Apr 2000 09:40:26 +0000 |
| Subject: | PHP4 and JPEG How To (was Re: GD 1.8.1/PHP RC1) | ||
| References: | 1 | Groups: | php.dev php.version4 |
| Request: | Send a blank email to php-dev+get-18033@lists.php.net to get a copy of this message | ||
Hello,
> I recently saw on the php.net site that support was added to PHP 4 RC1 for jpeg images
> in the GD library. I have been trying for about 10 hours now to make it work and cannot.
> specifically ImageCreateFromJpeg & ImageJpeg.
OK. Here's how I sucessfully got JPEG working in PHP4 :
1) download gd ( http://www.boutell.com/gd/ )
2) Decompress gd
$tar xvzf gd-1.8.1.tar.gz
3) Edit gd's Makefile to fit your needs
$cd gd-1.8.1/
$vi Makefile
You've to tell gd that you want JPEG support in gd's Makefile :
CFLAGS=-O -DHAVE_JPEG
LIBS=-lm -lgd -lpng -lz -ljpeg
Also check where the files will be installed, for example :
INSTALL_LIB=/usr/local/lib/gd
INSTALL_INCLUDE=/usr/local/include/gd
4) Compile gd
$make
(optionnal) check that JPEG support has been
included in GD.
$nm libgd.a | grep GD_JPEG_VERSION
00000004 r GD_JPEG_VERSION
5) Install gd
$su
#make install
#exit
6) Configure PHP using your favorite options :
$cd ../php4
$./configure --prefix=/usr \
--with-apxs=/usr/local/apache/bin/apxs \
--with-shared-apached=/etc/httpd \
--with-config-file-path=/usr/lib \
--with-regex=apache \
--without-pcre-regex \
--enable-debug=no \
--enable-versioning \
--enable-safe-mode \
--enable-track-vars \
==> --with-gd=/usr/local \
==> --with-jpeg-dir=/usr \
--with-ttf=/usr/lib
Two notes :
1)"--with-gd=/usr/local" is used to find the following files :
/usr/local/lib/gd/gd.a
/usr/local/include/gd/gd*.h
2)"--with-jpeg-dir=/usr" is used to find the jpeg library :
/usr/lib/libjpeg.so
Then, I get in the output of ./configure :
checking whether to include GD support... yes (static)
checking for gdImageString16 in -lgd... yes
checking for compress in -lz... yes
checking for png_info_init in -lpng... yes
checking for gdImageColorResolve in -lgd... yes
checking for gdImageCreateFromPng in -lgd... yes
checking for gdImageCreateFromGif in -lgd... no
checking for libjpeg (needed by gd-1.8+)... yes
checking for jpeg_read_header in -ljpeg... yes
checking for gdImageCreateFromJpeg in -lgd... yes
You can also check php_config.h for the following :
#define HAVE_GD_JPG 1
7) Build PHP
$make
You can check for JPEG support with :
$nm ext/gd/gd.o | grep Jpeg
U gdImageCreateFromJpeg
U gdImageJpeg
8) Install PHP
$su
#make install
#exit
9) That's it ! (don't forget to restart apache, if that's
your situation).
10) Test :
<?php
Header("Content-type: image/jpeg");
$me=ImageCreateFromJPEG("me.jpg");
ImageJPEG($me);
?>
Enjoy ! :-)
Please check the "optionnal" tests if anything goes wrong.
Hope this helps,
Flavien Lebarbé.
--
Flavien LEBARBE OPEN CARE Support for Freedom
mailto:flebarbe@ocare.com http://www.ocare.com
Tel:+33 141430890 Fax:+33 141430891