Greetings

is there a workaround where imagick can do multiple color in a single text or paragraph
something like this

This is a fancy color

unfortunately. the user interface is a WYSIWYG , so what ever formatted text inputted it will regenerated using Imagemagick

here is the script which is far in developing the tools to create that output

$draw = new ImagickDraw();
$im = new Imagick( "imagefilename.jpg");

$draw->setFont( "Fonts/arial.ttf" );
$draw->setFontSize(12 );
$draw->setGravity( Imagick:: GRAVITY_NORTH ); // text location
// first text
$draw->setFillColor(new ImagickPixel("#AAAAAA"));
$im->annotateImage( $draw, 0, 0, 0, "This is" );
$im->drawImage($draw);
// end first text

// second text
$draw->setFillColor(new ImagickPixel("#BBBBBB"));
$im->annotateImage( $draw, 0, 0, 0, "a fancy" );
$im->drawImage($draw);
//end second text

// third text
$draw->setFillColor(new ImagickPixel("#CCCCCC"));
$im->annotateImage( $draw, 0, 0, 0, "color" );
$im->drawImage($draw);
// end third text

now the output generated here is that each text is overlapping each other

.. im assuming computing the x coordinate( pixel) for the text location, but it will be very difficulty since the text input is done via WYSIWYG

any one can point me to the right direction without computing the x and y coordinates of text

    It's certainly possible, but I am not familiar with the PHP class used for it. However, I do know how to do it in the command line:

    convert -font Calibri -pointsize 30 -fill pink label:"Multiple " -fill red label:"font " -fill green label:"colour" +append test.png

    This will give you an image with multiple colours.

    I'm guessing that the ImagickDraw class just contructs a command to be executed, so you may be able to work it out from the command.

      Write a Reply...