Question

I use Imagemagick (www.imagemagick.org)

Since i am on hostgator i also have imagick and magickwand installed.

I can do simple manipulation with imagick and magickwand but if i want to reproduce the advanced tutorials at imagemagick.org i fail.

Goal: make this working http://www.imagemagick.org/Usage/advanced/#jigsaw

Questions:

How can i do this with imagick or magickwand?

Could i somehow also communicate with the module imagemagick through command line, like exec(....)?

Thanks 4 short help

Was it helpful?

Solution 2

Okay. The solution using the command-line commands straight is like the following:

exec("/usr/lib/convert user/set/seinfeld/image/image/data/apple_cinema_30.jpg -edge .5 -blur 0x.5 jaw_ege.png");

so obviously you have to know the path to the module and set the path to the images correctly (a).

will update if necessary with the instructions for imagick/magickwand.

OTHER TIPS

You can use exec() or shell_exec().

For example:

exec('/path/to/your/imagick/convert jigsaw_tmpl.png -edge .5 -blur 0x.5 jigsaw_edge.png');

One more reminder, exec() will not work in PHP safe mode.

I think it is to complicated to be run in Imagick - not saying it could not be - and as said above the best bet would be Imagemagick command line and exec( ). Build it up one command at a time; you may be able to combine commands later. Do not use jpg for any intermediate images as you will start to loose quality.

It depends what effect you are after as Anthony has a Bash script you could use linked towards the bottom of that section of the page.

You can run that with php using exec: Upload the script to your server CHMOD it to either 755 or 777 depending on your server setup

// Run the script 
exec("/FULL PATH TO JIGSAW/jigsaw options input.jpg mask.png output.png 2>&1", $array); 
//Display any errors 
echo "<br>".print_r($array)."<br></pre>";

I do not know if this will work on a Hostgator account but I can not see why not.

Also I have not tried it and you need a mask image to go with your input image.

I have just tried this on my server and get an error: /bin/bash^M: bad interpreter: No such file or directory This means nothing to me!

Making one jigsaw piece using Anthony's images and code with Imagemagick commaand line and exec( )

exec("convert jigsaw_tmpl.png -edge .5 -blur 0x.5 jigsaw_edge.png");

$cmd = " holocaust_md.jpg \( jigsaw_edge.png -negate \) -geometry +365+96 ".
" -compose multiply -composite -crop 100x100+365+96 +repage ";

exec("convert $cmd jigsaw_outline.png");    

$cmd = " holocaust_md.jpg -crop 100x100+365+96! -background none -flatten ".
" +repage \( jigsaw_tmpl.png +matte \) -compose CopyOpacity -composite ".
" -rotate -20 -gravity center -crop 100x100+0+0 +repage ";          

exec("convert $cmd jigsaw_cutout.png");         

$cmd = " jigsaw_cutout.png \( +clone -channel A -separate +channel -negate ".
" -background black -virtual-pixel background -blur 0x2 -shade 120x21.78 ".
" -contrast-stretch 0% +sigmoidal-contrast 7x50%  -fill grey50 -colorize 10% ".
" +clone +swap -compose overlay -composite \) -compose In -composite ";

exec("convert $cmd jigsaw_bevel.png");            

$cmd = " jigsaw_bevel.png \( +clone -fill DarkSlateGrey -colorize 100% -repage +0+1 \) ".
" \( +clone -repage +1+2 \)  \( +clone -repage +1+3 \) \( +clone -repage +2+4 \) ".
" \( +clone -repage +2+5 \) -background none -compose DstOver -flatten";

exec("convert $cmd jigsaw_thickness.png");

$cmd = " jigsaw_thickness.png \( +clone -background Black -shadow 50x3+4+4 \) ".
" -background none -compose DstOver -flatten";

exec("convert $cmd jigsaw_shadow.png");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top