$draw = new ImagickDraw();
$bg = new Imagick($fileName);
$draw->setTextAlignment(Imagick::ALIGN_CENTER);
$draw->setFont($fontName);
$draw->setFontSize($fontSize);
$draw->setFillColor($fontColor);
$bg->annotateImage($draw, $x, $y, $angle, $text);
$bg->setImageFormat("png");
$bg->writeImage($outfileName)
$size = $bg->queryFontMetrics($draw, 'Ширина текста');
echo '<pre>'; var_dump($size); echo '</pre>';
$w = $size['textWidth'];
$h = $size['textHeight'];