Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Composite soft edge

Composite soft edge example
 // Create the mask with a blurred edge
$cmd = " -size 400x300 xc:none -fill black ".
" -draw \"circle 120,220 120,140\" -negate -channel A -blur 0x8 ";
exec("convert $cmd mask.png");

// Cut the hole out of the top image
$cmd = " -compose Dst_Out mask.png -gravity south $input14 -matte ";
exec("composite $cmd result_dst_out1.png");

// Put the top image over the bottom
$cmd = " $input20 result_dst_out1.png -geometry +60-20 -composite ";
exec("convert $cmd output_temp.jpg");

// Remove the part of the bottom image that is still showing
$cmd = " output_temp.jpg -crop 400x280+60+0 ";
exec("convert $cmd composite_sunflower_soft.jpg ");

// Delete the tempory images
unlink("mask.png");
unlink("result_dst_out1.png");
unlink("output_temp.jpg");

Back