note 80751 added to function.imagick-queryfontmetrics
| From: | waage at osu1 dot php dot net | Date: | Wed, 30 Jan 2008 15:57:10 +0000 |
| Subject: | note 80751 added to function.imagick-queryfontmetrics | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135619@lists.php.net to get a copy of this message | ||
You can use this to center a text within a box
<?php
$data = "Hello world";
$text = new ImagickDraw();
$text->setFontSize(12);
$text->setFont("Arial");
$boxWidth = 210;
$im = new Imagick();
$fm = $im->queryFontMetrics($text, $data, false);
$textXLoc = ($boxWidth / 2) - ($fm["textWidth"] / 2);
?>
$textXLoc is now the starting location you need to use to feed to your annotateImage() function.
----
Server IP: 213.181.110.1
Probable Submitter: 157.157.96.98
----
Manual Page -- http://www.php.net/manual/en/function.imagick-queryfontmetrics.php
Edit -- https://master.php.net/note/edit/80751
Del: integrated -- https://master.php.net/note/delete/80751/integrated
Del: useless -- https://master.php.net/note/delete/80751/useless
Del: bad code -- https://master.php.net/note/delete/80751/bad+code
Del: spam -- https://master.php.net/note/delete/80751/spam
Del: non-english -- https://master.php.net/note/delete/80751/non-english
Del: in docs -- https://master.php.net/note/delete/80751/in+docs
Del: other reasons-- https://master.php.net/note/delete/80751
Reject -- https://master.php.net/note/reject/80751
Search -- https://master.php.net/manage/user-notes.php