//EXAMPLE - Center text
function newText($im, $size, $angle= 0, $x, $y, $color, $font, $text,$align = "left",$border=false,$width=0,$height=0){
if($align == "center")
{
if ($border == true ){
imagerectangle($im, $x, $y, $x +$width, $y + $height, $color);
}
$bbox = imageftbbox($size, 0, $font, $text);
// Marcamos el ancho y alto
$s_width = $bbox[4];
$s_height = $bbox[5];
$y = $y + ($height-$s_height)/2;
$x = $x + ($width-$s_width)/2;
}
imagettftext($im, $size, $angle, $x, $y, $color, $font, $text);
}