I still got problems trying to rotate imagettftext using imagettfbbox.
It's position calculation is mostly wrong. So i tried to rotate ttftext with IMAGEROTATE.
As a special the result is in black fontcolor and transparent background.
Hope it helps sombody (thanks for function convertBoundingBox, reading below)
<?
function ImgText($text,$fontsize,$font,$angle){
$im = '';
if($text){
if(!$fontsize || $fontsize < 1) $fontsize = 12;
if(!$font) $font = "fonts/arial.ttf";
$bbox = imagettfbbox($fontsize, 0, $font, $text);
$size=convertBoundingBox($bbox);
$im = ImageCreatetruecolor($size['width'],$size['height']);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0,0,0);
imagefill ($im, 0, 0, $white );
imagettftext($im, $fontsize, 0, $size['xOffset'], $size['yOffset'], $black, $font, $text);
$im = imagerotate( $im,$angle, $white);
imagecolortransparent ($im,$white);
}else{
// No text
}
}
?>