In my project, I need to merge two pictures.
The first (img.png):
And (for example) second (photo.png):
img http://uoops.ru/1/photo.png
This is PHP code:
$photoImage = ImageCreateFromPNG("img.png");
ImageAlphaBlending($photoImage, true);
$logoImage = ImageCreateFromPNG("photo.png");
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($photoImage, $logoImage, 1, 1, 0, 0, $logoW, $logoH);
ImagePNG($photoImage, "mrkr.png", 0);
As result I want to have this:
But I have this:
How can I fix this?
$photoImage = ImageCreateFromPNG("img.png");
$w = imagesx($photoImage);
$h = imagesy($photoImage);
$out = imagecreatetruecolor($w, $h);
ImageAlphaBlending($out, true);
imagefill($out, 0, 0, imagecolorallocatealpha($out, 0, 0, 0, 127));
imagesavealpha($out, true);
ImageCopy($out, $photoImage, 0, 0, 0, 0, $w, $h);
$logoImage = ImageCreateFromPNG("photo.png");
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
ImageCopy($out, $logoImage, 1, 1, 0, 0, $logoW, $logoH);
ImagePNG($out, "mrkr.png", 0);
this is not really optimized but should work