STOP! Do you have PHP 4.3 or better? Then you DON'T want this page. Just build PHP with gd enabled (--enable-gd) to get the built-in gd distribution in any newer version of PHP. Thank you.
* * *
The problem: a change in gd 2.0.2 and up broke compatibility with the PHP extension for gd. Oops.
The long-term fix: the PHP maintainers tell me they already have this fixed in the CVS tree for the next release of PHP.
The RIGHT NOW fix: I have made a patch available.
As an added bonus, this patch adds support for the nifty new
gdImageCopyRotated function, found in gd 2.0.8 and above!
THIS PATCH DOES NOT HAVE THE OFFICIAL BLESSING OF THE PHP MAINTAINERS, although I don't know why they would mind.
INSTRUCTIONS (Please Follow Carefully)
- Step One: download and install gd 2.0.8 or better. See the gd manual if you have questions about this step.
- Step Two: download the PHP 4.2.3 source distribution. You have probably done this already. (If you can use a newer version of PHP, then DON'T USE this patch at all. See the message at the top of this page.)
- Step Three: download the patch file,
php-4.2.3-gd-2.0.8.patch, and save it to the directory where you saved the PHP source distribution. I recommend right-clicking on the above link and selecting the "save target as" option.
- Step Four: untar the PHP distribution, if you have
not already done so, and cd to the
- Step Five: type this command:
patch -p1 < ../php-4.2.3-gd-2.0.8.patch
- Step Six: type
make install, etc. as you would normally do for PHP. In my experience, you will probably have to specify
--with-zlib-dir=/usr/localat a minimum to get
configureto notice that gd is available, but your mileage may vary.
- Step Seven: enjoy! The new
imagecopyrotatedfunction is similar to
imagecopyresized, except with slightly different arguments:
dstImage, srcImage, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle. Note that the destination X and Y coordinates specify the center of the rotated version of the source rectangle. Also note that the angle is specified as an integer number of degrees (0-359).