Hello!
Thank you for your answer!
You were right, my description wasn't exact enough. The result I posted as the two screenshots are not the results basing on the posted code. But the posted code was the code which makes the trouble. I post the complete code at the end of this message.
What the code I posted in my last message is doing is to edit an image which is finally overlaying the monitor screen of the background image. Here is the input image:
And here is the background image:
This should make more clear what the code should do and what does not work correct if the input image is too large. Then there are such grey frames you recognized. This is from the original monitor screen as you can see. But the input image should of course perfectly overlap the monitor screen.
You can play a bit around with my code on the website
http://www.marcotomato.com/canvas/test/upload2.php if you want. (everybody can) There you can upload own images and let them been edited and placed onto the monitor screen of the background image. After uploading you must refresh the browser. A small bug.
Best regards
Marc
Code: Select all
<?php
$bg='background_image.png';
$coords=array(26,169,308,182,305,341,20,354); // clockwise
$image='input_image.png';
$bgsize = getimagesize($bg);
$isize = getimagesize($image);
exec("/usr/imagemagick/bin/convert -extent $bgsize[0]x$bgsize[1] -alpha on -mattecolor transparent -virtual-pixel transparent -distort BilinearForward '0,0 $coords[0],$coords[1] $isize[0],0 $coords[2],$coords[3] $isize[0],$isize[1] $coords[4],$coords[5] 0,$isize[1] $coords[6],$coords[7]' $image temp.png");
exec("/usr/imagemagick/bin/convert -size $bgsize[0]x$bgsize[1] xc:none -draw 'polygon $coords[0],$coords[1] $coords[2],$coords[3] $coords[4],$coords[5] $coords[6],$coords[7]' temp2.png");
exec("/usr/imagemagick/bin/composite -compose In temp.png temp2.png temp3.png");
exec("/usr/imagemagick/bin/composite -gravity center temp3.png background_image3.png result.png");
?>
<img src="result.png">