ID: 50183
Updated by: pajoye@php.net
Reported By: scratch65535 at att dot net
Status: Feedback
Bug Type: GD related
Operating System: W2K
PHP Version: 5.2.11
New Comment:
Quick note: imagecopymerge is not supposed to work with alpha. See the
examples code here: http://pierre.libgd.org/watermark/
Previous Comments:
------------------------------------------------------------------------
[2009-11-15 17:50:06] scratch65535 at att dot net
Expected:
http://www.kalleload.net/uploads/gricmj/suhmidvvdrvt.jpg
Got:
http://www.kalleload.net/uploads/otgxlc/fdahibpvswas.jpg
As I mentioned, I can get rid of the magenta - I left it in to show the
size of the "assembly" area. But that white background in the PNG
defeats me.
------------------------------------------------------------------------
[2009-11-15 17:31:56] pajoye@php.net
Upload the two images here: http://kalleload.net/, that will do
it just
fine.
------------------------------------------------------------------------
[2009-11-15 17:30:40] scratch65535 at att dot net
AT&T is my only web access, and they don't seem to support PHP. I can
upload screenshots if that's what you're looking for, but of course
they'll just be dead bitmaps.
------------------------------------------------------------------------
[2009-11-15 16:46:58] pajoye@php.net
Please provide a link to the image you get and what you would expect.
------------------------------------------------------------------------
[2009-11-15 16:38:18] scratch65535 at att dot net
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 this bug report at http://bugs.php.net/?id=50183&edit=1