View Full Version : Text on image with ImageCreate error

Len Whistler
01-25-2007, 07:28 PM
I'm working on a php script that will put text onto images. I get the following error but I have the .ttf font file in the same folder as the script. Line 11 is the last line in the code I posted. Any ideas why I get the error?

Warning: imagettftext(): Could not find/open font in /home/httpd/vhosts/stubby.ca/httpdocs/test/index.php on line 11

$image = ImageCreateFromGIF("test.gif");
$color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66);
$font = 'LAPLDB.TTF';
$fontSize = "10";
$fontRotation = "0";
$str = "Copyright 2007");

/* Shadow */
ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, $font, $str);

Eternity Angel
01-25-2007, 11:56 PM
PHP will look in the font folder of the local machine for the font, not the current directory where the file is. You need to directly specify where the font is. Something like this:


Make sure the case is proper and everything.