Platform: Gentoo linux 1.4rc2
Webserver: Apache 2.0.44
Php: 4.3.1
Configure script:
CPPFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib
./configure --prefix=/usr/local \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-exif \
--enable-track-vars \
--with-calendar=shared \
--enable-safe-mode \
--enable-magic-quotes \
--enable-trans-sid \
--enable-wddx \
--enable-ftp \
--with-xpm-dir=/usr/X11R6 \
--with-gd=/usr/local \
--enable-gd-native-ttf \
--enable-gd-imgstrttf \
--with-freetype-dir=/usr/local/include/freetype2/freetype \
--with-ttf=/usr/local \
--with-zlib \
--with-t1lib=/usr/local \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-openssl=/usr \
--with-mysql=/usr/local \
Relevant info returned by configuer:
checking for FreeType 1.x support... yes
checking for FreeType 2... yes
checking for T1lib support... yes
checking whether to enable truetype string function in GD... yes
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
checking for XpmFreeXpmImage in -lXpm... yes
no - FreeType 2.x is to be used instead
checking for T1_LoadFont in -lt1... yes
checking for gdImageString16 in -lgd... yes
checking for gdImagePaletteCopy in -lgd... yes
checking for gdImageCreateFromPng in -lgd... yes
checking for gdImageCreateFromGif in -lgd... no
checking for gdImageGif in -lgd... no
checking for gdImageWBMP in -lgd... yes
checking for gdImageCreateFromJpeg in -lgd... yes
checking for gdImageCreateFromXpm in -lgd... yes
checking for gdImageCreateFromGd2 in -lgd... yes
checking for gdImageCreateTrueColor in -lgd... no
checking for gdImageSetTile in -lgd... yes
checking for gdImageEllipse in -lgd... no
checking for gdImageSetBrush in -lgd... yes
checking for gdImageStringTTF in -lgd... yes
checking for gdImageStringFT in -lgd... yes
checking for gdImageStringFTEx in -lgd... no
checking for gdImageColorClosestHWB in -lgd... yes
checking for gdImageColorResolve in -lgd... yes
checking for gdImageGifCtx in -lgd... no
checking for gdImageCreate in -lgd... yes
Test link:
http://watson-wilson.ca/starfrontiers/images/title.php?size=35&text=Test
title.php:
<?
Header("Content-type: image/png");
// note - must use the absolute font path
// be careful about blank lines in your code which will output a blank and confuse browser
$font = "/usr/X11R6/lib/X11/fonts/truetype/arial.ttf";
$box = imagettfbbox($size, 0, $font, $text);
$xsize = $box[2]-$box[0]+10;
$ysize = $box[1]-$box[7]+10;
$xstart = ($xsize - ($box[2] - $box[0])) / 2;
$ystart = ($ysize - ($box[1] - $box[7])) / 2 - $box[7];
$im = imagecreate($xsize,$ysize);
$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0,0,0);
$trans=ImageColorTransparent($im,$white);
ImageTTFText($im, $size, 0, $xstart, $ystart, $black, $font, $text);
Imagepng($im);
ImageDestroy($im);
?>
This script should return the text Test as a png file using arial font. I've set this up using the same scripts on other servers with older versions of php. What have I missed?