Click to See Complete Forum and Search --> : imagettfbbox()
Carth
06-19-2008, 04:03 AM
Can someone tell me why imagettfbbox() isn't returning anything? I was using the result to create an image, and it was 0px by 0px. So I did some investigating and it isn't returning anything.
$boundingBox = imagettfbbox(16, 0, "times_new_roman", "test");
print_r($boundingBox);
There's no output, no array described. If I put some text either side of print_r() I just get that text. If the function isn't defined surely I would get an error. What am I doing wrong?
Phill Pafford
06-19-2008, 11:42 AM
Do you have the GD library FreeType?
http://us2.php.net/imagettfbbox
Note: This function requires both the GD library and the » FreeType library.
Carth
06-20-2008, 06:08 AM
Yes I have GD library with FreeType support enabled (says so on phpinfo()).
imagettftext() works to write text with a TrueType font. But imagettfbbox() isn't returning anything. I use the same font, size, text and rotation.
Phill Pafford
06-20-2008, 07:50 AM
I would look at the http error logs and see if anything is showing up
most of the time its here:
/var/log/httpd/error_log
Carth
06-22-2008, 07:28 AM
Unfortunately I don't have root access on the server and can't get there. Is there some other way? I ran the script from the command line because I thought that should show all errors and warnings, but it didn't have any problems, and there doesn't seem to be a switch to make it more verbose.
Carth
06-26-2008, 10:27 AM
Okay this is just a brick wall. I don't think I will be able to use this function because I can't think why it isn't working and nobody else has.
So, can anybody suggest an alternative? Is it possible for me to make my own? I need to know the pixel size of image to create to put some text in with imagettftext().
Carth
10-27-2008, 02:39 PM
In case anyone is interested (I imagine this is quite a common problem anyway): If you specify a font that it can't find, all of the GD library functions that take fonts will just do nothing at all, without an error message. In my case, I'd defined the font path somewhere that doesn't get called before I was using imagettfbbox().