There was recently a thread on this list discussing the installation
of php 4.1.x with gd-2.0.1 and freetype-2.0.8. The conclusion of
this discussion was that php-4.1.x requires gd-2.0.2 which has not
yet been released.

I have obtained a copy of a patch to gd written by Wez Furlong (who
also maintains PHP's gd interface). With this patch I have successfully
compiled php-4.1.2 with gd-2.0.1-patched and freetype-2.0.8.

In order to perhaps save others the grief I have been through over the
last couple of days, I am making this patch and my config available.


Get freetype 2.0.8 from
and install it (or install a package if your system has one).

Get the gd-2.0.1 tarball from
Get Wez's patch from:

Make sure you don't have any old gd libraries installed on your
system. If you have gd-1.8.4 installed PHP might not find the new
2.0.1 installation. Track down old libraries with:
find / -name "libgd.*" -print

Build gd with the patch and install it:

gzip -d gd-2.0.1.patch.wez.gz
tar -xzf gd-2.0.1.tar.gz
cd gd-2.0.1
patch -p1 < ../gd-2.0.1.patch.wez
# edit Makefile if desired - by default it installs into /usr/local
make install

Now continue with your PHP build in the normal manner. My relevant
PHP configure options are:


If you don't have these libraries all installed under /usr, make
the appropriate changes to these directives.

And a quick test PHP script:

  Header("Content-type: image/png");
  $im = ImageCreate(400, 100);
  $black = ImageColorAllocate($im, 0, 0, 0);
  $white = ImageColorAllocate($im, 255, 255, 255);
  ImageFtText ($im, 20, 0, 10, 20, $white,
    "This is a test 1234",

Note the array() as the last argument to ImageFtText(). It appears that
you can pass a multi-line string to ImageFtText, and the array may
contain an option to control line spacing. e.g.
ImageFtText ($im, 20, 0, 10, 20, $white,
  "This is a test\r\ntest\r\ntest\r\ntest\r\ntest\r\ntest",
  array("linespacing" => 0.5));
generates a block of text with half the normal line spacing.

Thanks to:
Wez Furlong for maintaining PHP's GD interface for the GD library (even if updates are slow :)
Ernie Dipko for his help resolving this problem.


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to