ID:               29315
 Updated by:       [EMAIL PROTECTED]
 Reported By:      k at ailis dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         GD related
 Operating System: Linux
 PHP Version:      4.3.8
-Assigned To:      
+Assigned To:      pajoye
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Side effect of the resizing method in imagecopyresampled.

Cannot be "fixed".

ImageCopyResamples is not good for each kind of images but is not that
bad for a "all-in-one" usage.

--Pierre


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

[2004-07-27 15:52:11] k at ailis dot de

No. I've downloaded and opened your bug.png with GIMP and 
I still see blue snow around the second line. So the bug 
is still there. 
 
You must use a viewer which can display alpha-transparency 
like GIMP, ImageMagick or a capable browser like Mozilla 
to see the bug.

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

[2004-07-27 15:36:52] [EMAIL PROTECTED]

http://tony2004.phpclub.net/dev/tmp/bug.png - is this what you need?
If yes - please, try the next CVS snapshot, it should be fixed now.

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

[2004-07-23 09:26:02] k at ailis dot de

I've installed this snapshot, The bug is still present. 
Here is the output of gd_info(): 
 
array(11) { 
  ["GD Version"]=> 
  string(27) "bundled (2.0.28 compatible)" 
  ["FreeType Support"]=> 
  bool(true) 
  ["FreeType Linkage"]=> 
  string(13) "with freetype" 
  ["T1Lib Support"]=> 
  bool(true) 
  ["GIF Read Support"]=> 
  bool(true) 
  ["GIF Create Support"]=> 
  bool(true) 
  ["JPG Support"]=> 
  bool(true) 
  ["PNG Support"]=> 
  bool(true) 
  ["WBMP Support"]=> 
  bool(true) 
  ["XBM Support"]=> 
  bool(true) 
  ["JIS-mapped Japanese Font Support"]=> 
  bool(true) 
}

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

[2004-07-23 01:10:28] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



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

[2004-07-22 09:56:53] k at ailis dot de

Description:
------------
Hello, 
 
I've also send this bug to Boutell (because it is a bug in 
the GD library, not in PHP) but I have the feeling that 
I'll not get an answer because of the message I got after 
submitting the bug.. So maybe someone is able to fix this 
bug in the GD library which is bundled with PHP. 
 
There seems to be a bug in gdImageCopyResampled which is 
triggered if an alphatransparent image is resampled. The 
bug can be reproduced with GD 2.0.28 (and also with the 
library bundled with PHP 4.3.8) with the code at the 
bottom of this message (It's a C source. I'm putting a PHP 
source into the "reproduce code" box) 
 
This example code sets the background color of the 
resulting image to transparent so it's easier to see the 
bug. Resampling an alpha-transparent image to a 
"binary-even" size (2^x, for example: 64x64) works fine, 
but other values (like 127x127 in this example) creates 
alpha transparent artifacts. Depending on the destination 
size of the resampling the artifacts are very different. 
 
To see these artifacts just compile the following code and 
start it. You will end up with an out.png which has two 
lines in it. The first one is correct (was resized to 
64x64), the second one (resized to 127x127) has snow 
around the line (only visible if you display the image 
with a viewer supporting PNG transparency) 
 
 
#include <gd.h> 
 
int main(int argc, char *argv[]) 
{ 
    gdImagePtr alpha_image, test_image; 
    FILE *file; 
    int transparent, black, blue; 
 
    // Create an alpha-transparent image with a black line 
in it 
    alpha_image = gdImageCreateTrueColor(128, 128); 
    gdImageAlphaBlending(alpha_image, 0); 
    gdImageSaveAlpha(alpha_image, 1); 
    transparent = gdImageColorAllocateAlpha(alpha_image, 
0, 0, 0, 127); 
    black = gdImageColorAllocate(alpha_image, 0, 0, 0); 
    gdImageFilledRectangle(alpha_image, 0, 0, 128, 128, 
transparent); 
    gdImageLine(alpha_image, 0, 0, 128, 128, black); 
 
    // Create a test background image 
    test_image = gdImageCreateTrueColor(256, 256); 
    blue = gdImageColorAllocate(test_image, 0, 0, 256); 
    gdImageColorTransparent(test_image, blue); 
    gdImageFilledRectangle(test_image, 0, 0, 256, 256, 
blue); 
 
    // Resample the alpha-transparent image onto the test 
image (working) 
    gdImageCopyResampled(test_image, alpha_image, 10, 10, 
0, 0, 
        64, 64, 128, 128); 
 
    // Resample the alpha-transparent image onto the test 
image (not working) 
    gdImageCopyResampled(test_image, alpha_image, 100, 
100, 0, 0, 
        127, 127, 128, 128); 
 
    file = fopen("out.png", "w"); 
    gdImagePng(test_image, file); 
    fclose(file); 
 
    return 0; 
} 
 

Reproduce code:
---------------
// Create an alpha-transparent image with a sample line in it
$alpha_image = imagecreatetruecolor(128, 128);
imagealphablending($alpha_image, false);
imagesavealpha($alpha_image, true);
$transparent = imagecolorallocatealpha($alpha_image, 0, 0, 0, 127);
$black = imagecolorallocate($alpha_image, 0, 0, 0);
imagefilledrectangle($alpha_image, 0, 0, 128, 128, $transparent);
imageline($alpha_image, 0, 0, 128, 128, $black);

// Create a test background image
$test_image = imagecreatetruecolor(256, 256);
$blue = imagecolorallocate($test_image, 0, 0, 255);
imagecolortransparent($test_image, $blue);
imagefilledrectangle($test_image, 0, 0, 256, 256, $blue);

// Resample the alpha transparent image onto the test image (working)
imagecopyresampled($test_image, $alpha_image, 10, 10, 0, 0,
    64, 64, 128, 128);

// Resample the alpha transparent image onto the test image (not
working)
imagecopyresampled($test_image, $alpha_image, 100, 100, 0, 0,
    127, 127, 128, 128);

// Output image
header('Content-type: image/png');
imagepng($test_image);


Expected result:
----------------
Both lines should be drawn without alpha-transparent 
artifacts around them. 

Actual result:
--------------
The second line has snow (alpha-transparent artifacts) 
around it. 


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


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

Reply via email to