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.
// Images saved as miff to ease deleting tempory images and stop jpg compression
// Make an inverted copy of the original
exec("convert House.jpg -flip temp.miff");
// Make a gradiant - transparent to white
exec("convert -size 300x600 gradient:none-\"#262b38\" gradient_fx_linear.miff ");
// Put the gradiant over the inverted image
exec("convert temp.miff gradient_fx_linear.miff -gravity south -composite temp3.miff ");
// Join the two images together
exec("convert House.jpg temp3.miff -append temp1.miff");
// Draw the red outline - just to confirm area to distort - STEP NOT REQUIRED
$cmd = " temp1.miff -draw \"fill none stroke red polygon 0,0 0,425, 282,425, 282,0\" ";
exec("convert $cmd before.miff");
// Draw the blue outline to show the distortion - STEP NOT REQUIRED
$cmd = " temp1.miff -draw \"fill none stroke blue polygon 0,0 0,425, 282,325, 282,100\" ";
exec("convert $cmd after.miff");
// Carry out the distortion - OLD METHOD OF DEFINING THE DISTORT CO-ORDINATES
// $cmd = "temp1.miff -matte -background \"#000\" -virtual-pixel background ".
// " -distort Perspective \"0,0 0,425, 282,425, 282,0, 0,0 0,425, 282,325, 282,100\" ";
//exec("convert $cmd Perspective_reflection.miff");
// Top-left x,y,x,y bottom-left x,y,x,y bottom-right x,y,x,y top-right x,y,x,y
$cmd = " temp1.miff -matte -background none -virtual-pixel background ".
" -distort Perspective \"0,0,0,0 0,282,0,282 425,282,425,282 425,0,425,100\" ";
exec("convert $cmd perspective_reflection.png");
// Delete tempory images
foreach (glob("*.miff") as $filename) {
unlink($filename);
}