From: seth at pricepages dot org
Operating system: Mac 10.4
PHP version: 5.1.6
PHP Bug Type: GD related
Bug description: imagecopyresized() not compatable with alpha channel
Description:
------------
imagecopyresampled() should be copying the alpha channel, but
it doesn't seem to be doing so. This is a palette based source
image being copied to a true color image.
If you use imagecopy() instead, the image copies as expected
(mostly).
Reproduce code:
---------------
<?php
$small = imagecreatefrompng('http://leopold.sage.wisc.edu/test.png');
$width = 300;
$height = 300;
$srcW = imagesx($small);
$srcH = imagesy($small);
$img = imagecreatetruecolor($width, $height);
//Make a transparent canvas
$trans = imagecolorresolve($img,255,255,255);
imagecolortransparent($img, $trans);
imagealphablending($img, false);
imagefilledrectangle( $img,
0, 0,
$width, $height,
$trans);
//This shouldn't *need* to be on, but it does
imagealphablending($img, true);
//One of these works, the other doesn't
//imagecopy($img, $small, 0,0, 0,0, $srcW, $srcH);
imagecopyresized($img, $small, 0,0, 0,0, $width, $height, $srcW, $srcH);
header('Content-Type: image/png');
imagepng($img);
?>
Expected result:
----------------
An enlarged, pixellated, mostly transparent, image.
Actual result:
--------------
A black, opaque, image.
--
Edit bug report at http://bugs.php.net/?id=39273&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39273&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39273&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39273&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39273&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39273&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39273&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39273&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39273&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39273&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39273&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39273&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39273&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39273&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39273&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39273&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39273&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39273&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39273&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39273&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39273&r=mysqlcfg