Gracias ^^ He logrado esto:
Código PHP:
header("Content-type: image/jpeg");
$img = imagecreatetruecolor(500,400);
$bbox = imagettfbboxextended(50,0,"ttf/Trebuchet MS.ttf","g a b o..");
$timg = imagecreatetruecolor($bbox["width"],$bbox["height"]);
$bgcolor = imagecolorallocate($timg,255,255,255);
imagefill($timg,0,0,$bgcolor);
$txtcolor=imagecolorallocatealpha($timg,0,0,0,90);
imagettftext($timg,50,0,$bbox["x"],$bbox["y"],$txtcolor,"ttf/Trebuchet MS.ttf","g a b o..");
imagealphablending($img,true);
$bgcolor = imagecolorallocate($img,255,255,255);
imagefill($img,0,0,$bgcolor);
imagecopy($img,$timg,50,50,0,0,$bbox["width"],$bbox["height"]);
imagejpeg($img,"",100);
imagettfbboxextended():
Código PHP:
function imagettfbboxextended($size, $angle, $fontfile, $text) {
/*this function extends imagettfbbox and includes within the returned array
the actual text width and height as well as the x and y coordinates the
text should be drawn from to render correctly. This currently only works
for an angle of zero and corrects the issue of hanging letters e.g. jpqg*/
$bbox = imagettfbbox($size, $angle, $fontfile, $text);
//calculate x baseline
if($bbox[0] >= -1) {
$bbox['x'] = abs($bbox[0] + 1) * -1;
} else {
//$bbox['x'] = 0;
$bbox['x'] = abs($bbox[0] + 2);
}
//calculate actual text width
$bbox['width'] = abs($bbox[2] - $bbox[0]);
if($bbox[0] < -1) {
$bbox['width'] = abs($bbox[2]) + abs($bbox[0]) - 1;
}
//calculate y baseline
$bbox['y'] = abs($bbox[5] + 1);
//calculate actual text height
$bbox['height'] = abs($bbox[7]) - abs($bbox[1]);
if($bbox[3] > 0) {
$bbox['height'] = abs($bbox[7] - $bbox[1]) - 1;
}
return $bbox;
}
Extraída de php.net
Gracias ^^
Exitos.