From: scratch65535 at att dot net Operating system: W2K PHP version: 5.2.11 PHP Bug Type: GD related Bug description: PNG alpha blending doesn't seem to work
Description: ------------ I am trying to combine PNG images by 'pasting' them onto a transparent background such that I end up with one large image (the 'assembly') rather than a multitude of small ones. I'm using PNG because I need more than 8 bits/pixel. I created the images in p'shop 7. Using a GIF works fine, apart from it having too few bits per pixel. Using a PNG with a designated xparent color ("GIF mode", as it were) also works fine. PNG with alpha doesn't. I don't know whether the problem is in the documentation, in imageCreateFromPNG(), in my understanding, or somewhere else. I've fooled around with different combinations (e.g., putting in or taking out imageAlphaBlending() for the $dest value) but nothing seems to help. (Using PNGs in 'GIF mode' will be my fallback if alpha is broken, but it would mean re-doing all my images so I'm hoping alpha is NOT broken) Reproduce code: --------------- $png = 1 ; if ( $png == 1 ) // png in 'gif mode' { $dest = imageCreateTrueColor( 200, 200 ) ; $xparent = imageColorAllocate( $dest, 220,2,240 ) ; imageFilledRectangle($dest, 0,0, 200,200, $xparent) ; imageColorTransparent($dest, $xparent); $src = imageCreateFromPNG( 'TESTcolor.png' ) ; $srcxparent = imageColorAllocate( $src, 0xFF,0,0xFF ) ; imageColorTransparent($src, $srcxparent ) ; imageCopyMerge( $dest, $src, 50, 50, 0, 0, 100, 100, 100 ) ; header('Content-Type: image/png') ; imagePNG( $dest ) ; } else // png with alpha { $dest = imageCreateTrueColor( 200, 200 ) ; $xparent = imageColorAllocateAlpha( $dest, 0xFF,0x99,0xFF, 0 ); imageFilledRectangle($dest, 0,0, 200,200, $xparent) ; imageAlphaBlending( $dest, 1 ) ; imageSaveAlpha( $dest, 1 ) ; $src = imageCreateFromPNG( 'TESTalpha.png' ) ; imageAlphaBlending( $src, 1 ) ; imageSaveAlpha( $src, 1 ) ; imageCopyMerge( $dest, $src, 50, 50, 0, 0, 100, 100, 100 ) ; header('Content-Type: image/png') ; imagePNG( $dest ) ; } Expected result: ---------------- I expect to see a dark blue outline box on the background color of the page itself. Actual result: -------------- I see a dark blue outline box on an opaque white field overlaying the assembly field that I painted magenta. I can get rid of the magenta by calling imageColorTransparent() on $dest, but nothing I can do gets rid of the white background of the box. -- Edit bug report at http://bugs.php.net/?id=50183&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50183&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50183&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50183&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50183&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50183&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50183&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50183&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50183&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50183&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50183&r=support Expected behavior: http://bugs.php.net/fix.php?id=50183&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50183&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50183&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50183&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50183&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50183&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50183&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50183&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50183&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50183&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50183&r=mysqlcfg