Page 1 of 1

How can I implement complex im code?

Posted: 2007-08-21T11:01:06-07:00
by hknight
Hello,

I have had a nightmare trying to get my PHP button generator to work with ImageMagick / exec().

How easily could this be done with Imagick?

Thanks!

Code: Select all

convert -background transparent -fill transparent \
           -font 'tahomabd.ttf' -pointsize 13 label:'Open Houese' \
           -format 'viewbox 0 0 %[fx:w+7] %[fx:h+7]  \
 fill red roundRectangle 1,1 %[fx:w+5] %[fx:h+5] \
 5,5' \
            info: > rounded_corner.mvg

convert -background transparent +antialias rounded_corner.mvg mask.png

convert mask.png \
            \( +clone -fx A +matte  -blur 0x21  -shade 118x0 -normalize \
               -sigmoidal-contrast 16,60% -evaluate Multiply .4 \
               -roll +5+10 +clone -compose Screen -composite \) \
            -compose In  -composite  gel.png

convert gel.png \
            \( +clone -fx A  +matte -blur 0x2  -shade 0x90 -normalize \
               -blur 0x2  -negate -evaluate multiply .4 -negate -roll -.5-1 \
               +clone  -compose Multiply -composite \) \
            -compose In  -composite  gel2.png

convert gel2.png \
            -font 'tahomabd.ttf' -pointsize 11  -fill white +antialias  \
            -gravity Center  -annotate 0 "Open House"  -trim -repage 0x0+3+3 \
            \( +clone -background '#111111' -shadow 20x3+3+3 \) +swap \
            -background none  -flatten gel_button.png

Re: How can I implement complex im code?

Posted: 2007-08-21T17:11:04-07:00
by ridera
Should be fairly straightforward. Generally Imagick commands are derived from Imagemagick commands [e.g., draw, font, etc.]

Here is a code snippet to illustrate a simple case.

Code: Select all

//Instigate new Imagick objects.
	$image= new Imagick();					//Image objects; for the working "canvas(es)"
	$draw=	new ImagickDraw();				//Drawing tools objects; container for shape and text layers
	$color=	new imagickPixel();				//Color tools objects; container for pixel colors

	$color->setColor('skyblue');
	$image->newImage(400, 200, $color);		//Create the working image canvas, in pixels

	$color->setColor('blue');
	$draw->setStrokeColor($color);			//Outline color for the next draw operation
	$color->setColor('lightyellow');
	$draw->setFillColor($color);			//Fill color for the next draw operation

	$draw->rectangle(0, 0, 120, 100);	     //Draw a rectangle in the upper left, in pixels

	$color->setColor("darkred");			//font color
	$draw->setFillColor($color);
	$draw->setFont("Bookman-DemiItalic");	//Set the font
	$draw->setFontSize(60);			      //Font pixels size

	$draw->annotation(20, 160, 'Test');	   //Add annotation layer. Note that the stroke color is the last one assigned

	$image->drawImage($draw);		   //Add all drawing layers to image canvas

	$image->SetImageFormat('jpeg');
	$image->writeImage('Imagick_ex.jpg');	//Write jpg file in current directory. Directory must have proper permissions

	echo "<img alt=\"image missing\" src=\"./Imagick_ex.jpg\">\n\n";

Re: How can I implement complex im code?

Posted: 2008-02-20T17:09:21-07:00
by mkoppanen
Hi,

I don't the browsers support embedding the image contents into the HTML. Effectively you would be doing the same as copy pasting the image contents into your HTML.

In your HTML side use <img src=""> tag.