This is my code:
$text_array = array("Joel", "Almeida", "GarcÃa", "Joel Almeida GarcÃa");
$text = $text_array[rand(0, count($text_array)-1)];
$im = imagecreate(50, 22);
$bgColor = imagecolorallocate($im, 255, 255, 255);
$fgColor = imagecolorallocate($im, 0, 0, 0);
imagecolortransparent($im, $bgColor);
imagestring($im, 2, 0, 0, $text, $fgColor);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
The above code, creates a png image from a random text....my question is: How can I calculate, by code, the corrrect values width and height of imagecreate, based on the returned text?
Thanks