bobinindia Posted April 14, 2008 Share Posted April 14, 2008 I have this script that merges two images. The really.png was created using a transparent white background. That means that any pixel with 255,255,255 becomes transparent. I wanted to limit it to the edges of the image. I think i am hopeful. When merging in the code below holes apppear where there is were white pixels in really.png. Any way around this? <?php $image = imagecreatefromjpeg($coin_url['template_url']); $insert = imagecreatefrompng("really.png"); $image = image_overlap($image, $insert); function image_overlap($background, $foreground){ $insertWidth = imagesx($foreground); $insertHeight = imagesy($foreground); $imageWidth = imagesx($background); $imageHeight = imagesy($background); $halfx = ($imageWidth-$insertWidth)/2; $halfy = ($imageHeight-$insertHeight)/2; $overlapX = $imageWidth-$insertWidth-$halfx; $overlapY = $imageHeight-$insertHeight-$halfy; imagecolortransparent($foreground,imagecolorat($foreground,0,0)); imagecopymerge($background,$foreground,$overlapX,$overlapY,0,0,$insertWidth,$insertHeight,100); return $background; } imagejpeg($image, 'output.jpg'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/101095-transparency-problem-with-gd/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.