note 106050 deleted from function.imagick-annotateimage by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 Oct 2011 15:46:25 +0000 |
| Subject: | note 106050 deleted from function.imagick-annotateimage by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183662@lists.php.net to get a copy of this message | ||
Note Submitter: martin at psinas dot com
----
An additional note to Alan's comment below. If you set the gravity to SOUTHEAST (or the bottom
right) then the X value will offset the text by padding the right-hand side, not the left as manual
describes above.
For example:
<?php
// Create objects
$image = new Imagick('myImage.png');
// Watermark text
$text = 'Copyright';
// Create a new drawing palette
$draw = new ImagickDraw();
// Set font properties
$draw->setFont('Bookman-Demi');
$draw->setFontSize(20);
$draw->setFillColor('black');
// Position text at the bottom-right of the image
$draw->setGravity(Imagick::GRAVITY_SOUTHEAST);
// Draw text on the image
$image->annotateImage($draw, 10, 12, 0, $text);
// Draw text again slightly offset with a different color
$draw->setFillColor('white');
$image->annotateImage($draw, 11, 11, 0, $text);
// Set output image format
$image->setImageFormat('png');
// Output the new image
header('Content-type: image/png');
echo $image;
?>