note 105708 modified in function.imagick-annotateimage by danbrown
| From: | danbrown@php.net | Date: | Thu, 08 Sep 2011 16:14:25 +0000 |
| Subject: | note 105708 modified in function.imagick-annotateimage by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183039@lists.php.net to get a copy of this message | ||
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox');
If the third parameter, the 'Y' value, is 0, the text will be invisible because the text
is printed ABOVE the image - not on the image.
The solution is to start, depending on your chosen font size, with a Y value of about 40 and
experiment.
[Also:]
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.
<?php
$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.
--was--
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox');
If the third parameter, the 'Y' value, is 0, the text will be invisible because the text
is printed ABOVE the image - not on the image.
The solution is to start, depending on your chosen font size, with a Y value of about 40 and
experiment.
http://php.net/manual/en/function.imagick-annotateimage.php