ID:               26144
 User updated by:  sprice at wisc dot edu
 Reported By:      sprice at wisc dot edu
 Status:           Open
 Bug Type:         GD related
 Operating System: Mac 10.3
 PHP Version:      4.3.4
 New Comment:

After looking through the source code more, I think that 
this is caused (at least in part) by always converting 
the rotated image to a true color image, which always 
initially has the background color of black. This is 
also why the background color argument of the 
imageRotate() function seems to have no effect. This is 
shown in /ext/gd/libgd/gd.c on lines 2654, 2691, and 
2728 (among others).

I think a fix to this would be to make GD return a true 
color image only when the input is true color. Otherwise 
return an image with palette biased colors. This 
*should* keep the alpha channel a bit more intact than 
previously. Don't expect a patch from me any time soon 
though, because I have homework and classes now, and I 
only know enough C to be dangerous...


Previous Comments:
------------------------------------------------------------------------

[2003-11-05 21:46:56] sprice at wisc dot edu

./configure --with-apxs --with-mysql --with-gd --with-
png-dir=/usr/local --with-zlib-dir=/usr --with-jpeg-
dir=/usr/local --disable-short-tags

(and phpinfo() says it is the bundled, 2.0.15 compat. 
version)

Is this not reproducible?

------------------------------------------------------------------------

[2003-11-05 21:39:11] [EMAIL PROTECTED]

And what might have been the configure line you used?
If you didn't use the bundled GD library, bogus this yourself..


------------------------------------------------------------------------

[2003-11-05 19:46:04] sprice at wisc dot edu

Tried it with latest/greatest CVS (php4-STABLE
-200311060030) and it is still broken.

------------------------------------------------------------------------

[2003-11-05 17:55:24] [EMAIL PROTECTED]

This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.



------------------------------------------------------------------------

[2003-11-05 17:52:49] sprice at wisc dot edu

Description:
------------
ImageRotate() is messing with my alpha channel. Examples 
to follow.

Reproduce code:
---------------
<?php
header( 'Content-type: image/png' );
$img = ImageCreate(100, 60);

$white = ImageColorResolve($img, 255, 255, 255);
$almost_clear = ImageColorResolveAlpha($img, 1, 1, 250, 63);

ImageFilledRectangle($img, 0, 0, 50, 30, $white);
ImageFilledRectangle($img, 10, 10, 100, 60, $almost_clear);

ImagePNG($img); // This works
//ImagePNG(ImageRotate($img, 90, $almost_clear)); // This is all black
?>

Expected result:
----------------
When you run this as is, you get a semitransparent blue 
rectangle.

Actual result:
--------------
If you replace the commented out ImagePNG() 
with the commented one, the alpha channel inverts 
itself. As you increase the transparency of 
$almost_clear, it becomes black (in contrast to the non-
ImageRotate() 
line).


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=26144&edit=1

Reply via email to