note 105712 deleted from function.imagick-annotateimage by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Sep 2011 16:14:38 +0000 |
| Subject: | note 105712 deleted from function.imagick-annotateimage by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183040@lists.php.net to get a copy of this message | ||
Note Submitter: www dot query at gmail dot com
----
When wishing to print some text on a photograph and make that text sufficiently contrasting to the
background image, use a 4 byte code for colour and transparency.
It is the same 4 byte code using by the parameter '-undercolor' in ImageMagick's
command lime instruction 'convert'.
The first 3 bytes are the RGB colour code and the fourth byte is the transparency byte.
<?
$picin = new Imagick($pic1);
$picin->scaleimage(800,0);
$height = $picin->getimageheight();
$draw = new ImagickDraw();
$draw->setFillColor('#ffff00');
$draw->setFont('Eurostile');
$draw->setFontSize(21);
$draw->setTextUnderColor('#ff000088');
$picin->annotateImage($draw,40,$height-10,0,"Hallo");
$picin->writeimage($pic6);
?>
The example code produces yellow text on a semi-transparent red background.
$pic1 and $pic6 were previously defined as directory/file strings.