From:             vbhunt at silverfox dot com
Operating system: Windows XP Professional Ver 2SP2
PHP version:      5.2.5
PHP Bug Type:     GD related
Bug description:  imagecreatefrompng does not set transparent color

Description:
------------
I want to overlay an icon on a button image.  The icon is a 32 x 32 pixel
png file with transparency. Icon was built in Photoshop 7.01 and tested for
transparency on FireFox 2.0.0.11 and IE 7.0.5730.13. The button image is a
jpeg.  I expected the Icon to overlay part of the jpeg image showing
through the transparent png pixels as they do in IE and FF.  Instead, the
pixels are turned white.  I have written and tested the following simple
script that reproduces the bug on my system.  I expect the script to report
the transparent color if there is one.  

This bug has been reported previously as 12619 which was dismissed as
"bogus" but notes that if you have additional information, submit it. 
 
When I attempted to comment on it (upon invitation) I get the message,
"You can not comment bogus reports or change their status."  Therefore I'm
re-submitting this ;-)

Reproduce code:
---------------
<?php
function testTransparency( $filename )
{ error_log( "Entering testTransparency." );
  $rsc = null;
  if ( $ext = pathinfo($filename,PATHINFO_EXTENSION) ) // if an image
    switch( strtolower( $ext ) )
    { case "gif" : $rsc=imagecreatefromgif( $filename ); break;              
case "png" : $rsc=imagecreatefrompng( $filename ); break;
      case "jpg" : $rsc=imagecreatefromjpeg( $filename ); break;
    }
  if ( $rsc )
  { $tpColor = imagecolortransparent($rsc);
    $trueColor=(imageistruecolor($rsc))? 'true color':'indexed color';
    if ( $tpColor == -1 ) $tpColorString = 'no transparency';
    else
    { $tpColor=(imageistruecolor($rsc))?$tpColor 
              : imagecolorsforindex($rsc, $tpColor);
      $red = ($tpColor>>16)&0xFF; $green = ($tpColor >>8)&0xFF;
      $blue = ($tpColor>>00)&0xFF;
      $tpColorString = 'transparency color: Red=' 
                     . dechex($red) . ' Green='. dechex($green) 
                     . ' Blue=' . dechex($blue) . ' ';
    }
    error_log("$filename $trueColor image has $tpColorString.");
    imagedestroy($rsc);
  }
  else error_log(" $filename is not a supported image.");
}
?>

Expected result:
----------------
I expected to see:

[05-Dec-2007 11:11:09] Entering testTransparency.

[05-Dec-2007 11:11:09] buttons/icons/stop1.png true color image has
transparency color: Red=0xFF Green=0xFF Blue=0xFF

but I got:

[05-Dec-2007 11:11:09] Entering testTransparency.

[05-Dec-2007 11:11:09] buttons/icons/stop1.png true color image has no
transparency.

I've tested this on 10 different png icon files with the same result.
All of these icons display with correct transparency in Firefox and IE as
reported above.


Actual result:
--------------
[05-Dec-2007 11:52:36] Entering testTransparency.
[05-Dec-2007 11:52:36] buttons/icons/alert.png true color image has no
transparency.

[05-Dec-2007 11:52:36] Entering testTransparency.
[05-Dec-2007 11:52:36] buttons/icons/home.png true color image has no
transparency.

The tests below actually do not have transparency.
[05-Dec-2007 11:52:36] Entering testTransparency.

[05-Dec-2007 11:52:36] buttons/images/hotmaples1_1.gif indexed color image
has no transparency.

-- 
Edit bug report at http://bugs.php.net/?id=43508&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43508&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43508&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43508&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43508&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43508&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43508&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43508&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43508&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43508&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43508&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43508&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43508&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43508&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43508&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43508&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43508&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43508&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43508&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43508&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43508&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43508&r=mysqlcfg

Reply via email to