|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-15 16:46 UTC] pajoye@php.net
[2009-11-15 17:30 UTC] scratch65535 at att dot net
[2009-11-15 17:31 UTC] pajoye@php.net
[2009-11-15 17:50 UTC] scratch65535 at att dot net
[2009-11-15 18:21 UTC] pajoye@php.net
[2009-11-15 18:26 UTC] scratch65535 at att dot net
[2009-11-15 18:29 UTC] scratch65535 at att dot net
[2009-11-23 01:00 UTC] php-bugs at lists dot php dot net
[2009-11-23 14:42 UTC] scratch65535 at att dot net
[2009-11-23 19:25 UTC] pajoye@php.net
[2010-06-14 10:42 UTC] pajoye@php.net
-Summary: What feedback is expected?
+Summary: PNG alpha blending doesn't seem to work
[2017-01-23 14:06 UTC] cmb@php.net
[2017-01-23 14:07 UTC] cmb@php.net
-Type: Bug
+Type: Documentation Problem
[2017-10-24 07:39 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: pajoye
+Assigned To:
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 22:00:02 2025 UTC |
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.