From:             seth at pricepages dot org
Operating system: Mac 10.4
PHP version:      5CVS-2006-11-02 (snap)
PHP Bug Type:     GD related
Bug description:  more imagecopyresized() alpha problems

Description:
------------
I'm not sure how many bugs are hidden here, but I thought 
this should be submitted.

imagecopyresized() is ignoring alpha the blending mode. 
Specifically, in ext/gd/libgd/gd.c line 2376 or so, there is 
this code that skips processing transparent pixels:
  tmp = gdImageGetPixel (src, x, y);
  if (gdImageGetTransparent (src) == tmp) {
      tox += stx[x - srcX];
      continue;
  }

But if the alpha blending is set to false, you want to copy 
the transparent pixels. So commenting out this if statement 
removes one bug. There is other similar code in this loop, 
so maybe it should all be removed?

Unfortunately, all result pixels still opaque, when the 
source image pixels are partially transparent. So this code 
does not fix the problem.

Reproduce code:
---------------
<?php
$small = imagecreatefrompng(
           'http://pricepages.org/temp/partialTrans.png');

$width = 300;
$height = 300;
$srcW = imagesx($small);
$srcH = imagesy($small);

$img = imagecreatetruecolor($width, $height);
$red = imagecolorresolve($img,255,0,0);
imagefill($img, 0,0, $red);
imagealphablending($img, false);

imagecopyresized($img, $small, 0,0, 0,0, $width, $height, $srcW, $srcH);

header('Content-Type: image/png');
imagepng($img);
?>

Expected result:
----------------
The image is filled with red, and a partially transparent 
black-and-white image is composited on top of it. Because 
alpha blending is set to false, there should be no red showing 
in the final image. (bug#1, squashed above)

Also, because the greyscale image should have partial 
transparency, there should be a gradient between black and 
red, but there is none. It is only black or only red. (bug#2)



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

Reply via email to