tags:

views:

97

answers:

1

I'm using the GD library for PHP, and using functions like imagestring() and imagestringup() to add text to pictures. I am using the built-in fonts with latin2 encoding. Is there a way, with a given string, to calculate the length (in pixels) of the string?

I want to calculate the length in pixels of the strings because the strings are variable and I want to make sure the string doesn't overflow the area I want to put it in.

Thanks for your help.

+5  A: 

imagettfbbox() does that: http://www.php.net/manual/en/function.imagettfbbox.php

Pekka