#23815 [NEW]: imagecopymerge doesn't respect alpha-channel in PNG-24 file

From: Date: Mon, 26 May 2003 16:43:06 +0000
Subject: #23815 [NEW]: imagecopymerge doesn't respect alpha-channel in PNG-24 file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40451@lists.php.net to get a copy of this message
From: bjorn at smokingmedia dot com Operating system: Linux pluto 2.4.18lvm-r1 PHP version: 4.3.1 PHP Bug Type: GD related Bug description: imagecopymerge doesn't respect alpha-channel in PNG-24 file [[There are similar bugs in the system, but they are either closed or said to be fixed... i think it's still not fixed..]] i wanted to do the following. Use a transparent PNG-24(24 bits) file, with an alpha-channel (with a drop-shadow) and merge it to a background color. (see sample code). this works: imagecopy($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y); this doesn't work: imagecopymerge($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y, 99); -> with any number instead of 99 sample link: [change the hex color code to change backgroundcolor] this is Okay http://www.smokingmedia.com/test_gd_fb/test?bg=ffee22 this is not okay: http://www.smokingmedia.com/test_gd_fb/test_nk?bg=ffee22 sample code: <?php if(!isset($_GET[bg]) || $_GET[bg] == ""){ $bg = "eeeeee"; } else{ $bg = $_GET[bg]; } $im = "test01.png"; // // function to convert hex colorcode to decimal // function colordecode($hex){ $code[r] = hexdec(substr($hex, 0 ,2)); $code[g] = hexdec(substr($hex, 2 ,2)); $code[b] = hexdec(substr($hex, 4 ,2)); return $code; } // end func colordecode // create the resource id $image_id = imageCreateFromPNG($im); // get image size $im_X = ImageSX($image_id); $im_Y = ImageSY($image_id); // create a truecolor background image of the right size $backgroundimage = imagecreatetruecolor($im_X, $im_Y); // get the desired backgroundcolor: $code = colordecode($bg); $backgroundcolor = ImageColorAllocate($backgroundimage, $code[r], $code[g], $code[b]); ImageFilledRectangle($backgroundimage, 0, 0, $im_X, $im_Y, $backgroundcolor); // merge the two together with alphablending on! ImageAlphaBlending($backgroundimage, true); // this works: imagecopy($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y); // this is where things go wrong: //imagecopymerge($backgroundimage, $image_id, 0, 0, 0, 0, $im_X, $im_Y, 99); // output the image: Header( "Content-type: image/png"); ImagePNG($backgroundimage); // destroy the memory ImageDestroy($backgroundimage); ImageDestroy($image_id); ?> -- Edit bug report at http://bugs.php.net/?id=23815&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23815&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23815&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23815&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23815&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23815&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23815&r=support Expected behavior: http://bugs.php.net/fix.php?id=23815&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23815&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23815&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23815&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23815&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23815&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23815&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23815&r=gnused

« previous php.bugs (#40451) next »