$info = getimagesize($src);
$image = imagecreatefrompng($src); // or based on $info
$fontBox = imagettfbbox($fontSize,0,$font,$content);
$x = ( $info[0] - $fontBox[2]) / 2;
imagettftext($image,$fontSize,0,$x,$y,$color,$font,$content);

Return array indexes 0..7 represent the bounding box corners.