image processing - Strange result of making one picture from to on PHP -
in project, need merge 2 pictures.
the first (img.png):
and (for example) second (photo.png):
img http://uoops.ru/1/photo.png
this 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 want have this:
but have this:
how can 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 not optimized should work
Comments
Post a Comment