Link to home
Start Free TrialLog in
Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal

asked on

Imagick Font Color

Hi E's, I use the code in snippet code for put watermark in the image. In this case the watermark was text ('protected picture') and that text will appear in the center of the picture.
The problem is I don't know how I define the color of the watermark text, always appear in black tone (depend of 'setFillAlpha' can be black to gray).
I want put the watermark text in green color.

Can you tell me how I change the color of watermark text?

Regards, JC
<?php
try
{
    /*** the image file ***/
    $image = 'imagem.jpg';

    /*** a new imagick object ***/
    $im = new Imagick();

    /*** read the image into the object ***/
    $im->readImage( $image );

    /* Create a drawing object and set the font size */
    $draw = new ImagickDraw();

    /*** set the font ***/
    $draw->setFont( "CALIBRI.TTF" );

    /*** set the font size ***/
    $draw->setFontSize( 25 );

    /*** add some transparency ***/
    $draw->setFillAlpha( 10 );

    /*** set gravity to the center ***/
    $draw->setGravity( Imagick::GRAVITY_CENTER );

    /*** overlay the text on the image ***/
    $im->annotateImage( $draw, 0, 0, 25, "protected picture" );

    /**** set to png ***/
    $im->setImageFormat( "jpg" );

    /*** write image to disk ***/
    $im->writeImage( 'imagem2.jpg' );

    echo 'Image Created';
}
catch(Exception $e)
{
    echo $e->getMessage();
}
?>
<img src="imagem2.jpg" />

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ante0
Ante0
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial