Shadow Jolteon Posted December 17, 2008 Share Posted December 17, 2008 Hello. My friend and I have been trying to combine two PNG format images using this: <?php $background = htmlspecialchars($_GET['bg']); $avatar = htmlspecialchars($_GET['av']); $av = imagecreatefrompng('img/avatars/'.$avatar.'.png'); $bg = imagecreatefrompng('img/avatars/backgrounds/'.$background.'.png'); $sx = imagesx($av); $sy = imagesy($av); imagecopy($bg, $av, imagesx($bg) - $sx - $marge_right, imagesy($bg) - $sy - $marge_bottom, 0, 0, imagesx($av), imagesy($av)); header('Content-type: image/png'); imagepng($bg); imagedestroy($bg); ?> Everything works fine, except the transparency of the image is lost. I was just wondering if there is anyone here who knows how to fix this problem. Thanks! Link to comment https://forums.phpfreaks.com/topic/137302-combining-png-images-with-transparency/ Share on other sites More sharing options...
xtopolis Posted December 17, 2008 Share Posted December 17, 2008 Doing a quick google search, try this: http://us2.php.net/manual/en/image.examples.merged-watermark.php imagecopymerge() instead of imagecopy() Link to comment https://forums.phpfreaks.com/topic/137302-combining-png-images-with-transparency/#findComment-717379 Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 i have had the same problem. i used the following code right after i imagecopy'ed them together. depending on gd versions, etc, it may work... # Turn off alpha blending and set alpha flag imagealphablending($bg, false); imagesavealpha($bg, true); if it doesn't work, i may help to debug further. Link to comment https://forums.phpfreaks.com/topic/137302-combining-png-images-with-transparency/#findComment-717381 Share on other sites More sharing options...
Shadow Jolteon Posted December 17, 2008 Author Share Posted December 17, 2008 i have had the same problem. i used the following code right after i imagecopy'ed them together. depending on gd versions, etc, it may work... # Turn off alpha blending and set alpha flag imagealphablending($bg, false); imagesavealpha($bg, true); if it doesn't work, i may help to debug further. Awesome, that worked. Thank you very much for your assistance! Thanks to you, too, xtopolis. ^^ Link to comment https://forums.phpfreaks.com/topic/137302-combining-png-images-with-transparency/#findComment-717391 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.