Page 1 of 1
Can my complex actions be done with IMagick?
Posted: 2007-08-28T11:04:41-07:00
by hknight
Hello,
I do some really funky things with ImageMagick, thanks to some help from Anthony.
For example, to add a gradient to a button I have to use ImageMagick to calculate the size of the button, write that size to a text file, then read that text file later.
Can this be done with IMagick?
Please review the file attachment and tell me if this can be done STRICTLY with IMagick, without the use of exec().
Thanks!
Re: Can my complex actions be done with IMagick?
Posted: 2007-08-28T11:31:26-07:00
by mkoppanen
Yes, I took a quick look and it looks doable.
Heres an example of a little more complicated drawing operation using imagick:
http://phpfi.com/259259
--
Mikko Koppanen
Re: Can my complex actions be done with IMagick?
Posted: 2007-08-29T17:18:44-07:00
by ridera
Here's an example I used to get started with Imagick:
/* This is the IM command version:
-size 900x85 xc:#ffffee -font Bookman-DemiItalic -pointsize 30 -draw "text 10,60 'Image created and saved: 9 Aug 2007 02:36:38 PM'" -channel RGBA -gaussian 0x6 -fill darkred -stroke magenta -draw "text 5,55 'Image created and saved: 9 Aug 2007 02:36:38 PM'"
*/
Then I just took each IM command and used the Imagick equivalent. Some of the parameters are slightly different.
Code: Select all
$obj2= new Imagick(); //Object
$draw= new ImagickDraw(); //Drawing objects
$color= new ImagickPixel(); //Pixels color objects
$text= 'Image created and saved: ' . date('j M Y h:i A');
$width= 940;
$height= 85;
$font_size= 32;
$left_margin= 30;
$top_margin= 55; //Text and shadow location
$label_img= './test_label.jpg';
$color->setColor('skyblue');
$obj2->newImage($width, $height, $color);
//Create the label image
$draw->setFont("Bookman-DemiItalic"); //Set the font
$draw->setFontSize($font_size); //Set the size
$color->setColor("black");
$draw->setFillColor($color);
$obj2->annotateImage($draw, $left_margin+5, $top_margin+5, 0, $text); //Add the text shadow
$obj2->gaussianBlurImage(0, 6); //Blur it
$color->setColor("darkred"); //Text color
$draw->setFillColor($color);
$color->setColor('magenta'); //Stroke color
$draw->setStrokeColor($color);
$draw->annotation($left_margin, $top_margin, $text); //Add pretty text
$obj2->drawImage($draw); //Add the text layer
/********* 3d Frame it ********************************/
/*
* The IM command: -mattecolor Blue -frame 10x10+0+6
*/
$color->setColor('blue');
$obj2->frameImage($color, 14, 14, 0, 8);
$obj2->SetImageFormat('jpeg');
$obj2->writeImage($label_img);
echo "<img alt=\"image missing\" src=\"./$label_img\">\n\n";