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'); ?> Link to comment https://forums.phpfreaks.com/topic/101095-transparency-problem-with-gd/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.