note 94239 added to function.imagickdraw-annotation
| From: | Anonymous at osu1 dot php dot net | Date: | Sat, 24 Oct 2009 17:28:28 +0000 |
| Subject: | note 94239 added to function.imagickdraw-annotation | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162034@lists.php.net to get a copy of this message | ||
Here's how to create a header image and write it to file. This took me a while to figure out.
I hope this helps.
<?php
/* Text to write */
$text = "Hello World!";
/* Create Imagick objects */
$image = new Imagick();
$draw = new ImagickDraw();
$color = new ImagickPixel('#000000');
$background = new ImagickPixel('none'); // Transparent
/* Font properties */
$draw->setFont('Arial');
$draw->setFontSize(50);
$draw->setFillColor($color);
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
/* Get font metrics */
$metrics = $image->queryFontMetrics($draw, $text);
/* Create text */
$draw->annotation(0, $metrics['ascender'], $text);
/* Create image */
$image->newImage($metrics['textWidth'], $metrics['textHeight'], $background);
$image->setImageFormat('png');
$image->drawImage($draw);
/* Save image */
file_put_contents('/path/to/file.png', $image);
?>
----
Server IP: 64.71.164.2
Probable Submitter: 24.208.213.112
----
Manual Page -- http://www.php.net/manual/en/function.imagickdraw-annotation.php
Edit -- https://master.php.net/note/edit/94239
Del: integrated -- https://master.php.net/note/delete/94239/integrated
Del: useless -- https://master.php.net/note/delete/94239/useless
Del: bad code -- https://master.php.net/note/delete/94239/bad+code
Del: spam -- https://master.php.net/note/delete/94239/spam
Del: non-english -- https://master.php.net/note/delete/94239/non-english
Del: in docs -- https://master.php.net/note/delete/94239/in+docs
Del: other reasons-- https://master.php.net/note/delete/94239
Reject -- https://master.php.net/note/reject/94239
Search -- https://master.php.net/manage/user-notes.php