I would put a logo image in another image, the two images are png, I try both functions imagecopy and imagecopymerge but nothing to do, I do not see the result when I open the image on the disk, however both functions returns true. Someone can help me, here is the code I use:
$data = substr($_POST['imageData'], strpos($_POST['imageData'], ",") + 1);
$decodedData = base64_decode($data);
$img = "assets\\images\\simulation\\user\\img777.png";
$srcpath = "assets\\images\\logo.png";
fp = fopen($img , 'wb');
fwrite($fp, $decodedData);
fclose($fp);//work until this place
$dest =imagecreatefrompng($img);
$src =imagecreatefrompng($srcpath);
imagecopy ($dest,$src, 0, 0, 0, 0, imagesx($src),imagesy($src));
// or imagecopymerge ($dest,$src, 0, 0, 0, 0, imagesx($src),imagesy($src), $pct); with $pct =0 or 50
/*or i have also try : $cut = imagecreatetruecolor(imagesx($src),imagesy($src));
imagecopy($cut, $dest, 0, 0, 0, 0, imagesx($src),imagesy($src));
imagecopy($cut, $src, 0, 0, 0, 0, imagesx($src),imagesy($src));
imagecopymerge ($dest,$cut, 0, 0, 0, 0, imagesx($src),imagesy($src), $pct); with $pct =0 or 50*/
here are a example for the image logo.png : http://upload.wikimedia.org/wikipedia/commons/4/48/EBay_logo.png
Here are the other image.png : http://www.noelshack.com/2014-40-1412264764-img68634dxn777.png
the result it's the same that image.png ...
can you help me, thanks.
I solved this problem with the following code:
imagealphablending($dest, true);
imagealphablending($src, true);
imagesavealpha($dest, true);
imagesavealpha($src, true);
imagecopy ($dest,$src, 5, imagesy($dest) - (imagesy($src)+5), 0, 0,imagesx($src),imagesy($src));
imagealphablending($dest, true);
imagesavealpha($dest, true);
imagepng($dest,$img);
imagedestroy($dest);
imagedestroy($src);
in place of :
$dest =imagecreatefrompng($img);
$src =imagecreatefrompng($srcpath);
imagecopy ($dest,$src, 0, 0, 0, 0, imagesx($src),imagesy($src));