#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread seth at pricepages dot org
 ID:   39273
 User updated by:  seth at pricepages dot org
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

I'm American; if I'm exposed to more than one language my head 
explodes. ;)

Yep, that image is exactly what I'm looking for.

Thanks for not just ignoring me after marking the bug bogus, 
I've had that happen also...


Previous Comments:


[2006-10-28 15:14:41] [EMAIL PROTECTED]

Sorry for my bad wording (images "speak" better), but we are getting
somewhere, finally. We were talking of two different problems. I was
talking about a common misunderstanding and you about a more specific
problem. Thanks to have insisted and nice catch :)

Check this image:
http://blog.thepimp.net/misc/39273_out.png

Is it what you expect?




[2006-10-28 14:43:21] seth at pricepages dot org

translucide (French) = translucent (English)

Sorry, that confused me for a bit.

"Boolean transparency" means that the pixel is either fully 
transparent, or fully opaque. Never partially transparent.

The area outside of the line is fine, it should be 
transparent and it is in your image. This is correct.

What is suffering from "boolean transparency" are the edges 
of the line. For example:

In your example script, one alpha value was 63, and the 
other was 127. In your output PNG, those values have been 
changed to 0 and 127.

I should mention that if you are using Microsoft's Internet 
Explorer version 6 or less, a PNG image will display with 
boolean transparency due to a bug in the browser. So you 
won't be able to see the difference. Use FireFox.



[2006-10-28 14:19:46] [EMAIL PROTECTED]

Pardon? What is a boolean transparency?

Please understand these three things:
- The transparent color is one *color*, an index for palette  based
image or 32bits value for truecolor images. It defines which color is
used as the *background* color (like white is   the background color of
a white paper).

- The *alpha* channel of a pixel defines how translucide the pixel has
to be. It has nothing to do with the transparent color.

- Your image has *no* transparent color but many pixels with various
*alpha* levels.

Load the result images in your favourite paint programs to see what I
mean. The area outside the line is translucide, it is due to the alpha
channel.




[2006-10-28 14:11:56] seth at pricepages dot org

But that has one of the bugs that I pointed out: boolean 
transparency. The original doesn't have that problem.



[2006-10-28 14:04:59] [EMAIL PROTECTED]

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png






The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39273

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


#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread pajoye
 ID:   39273
 Updated by:   [EMAIL PROTECTED]
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

Sorry for my bad wording (images "speak" better), but we are getting
somewhere, finally. We were talking of two different problems. I was
talking about a common misunderstanding and you about a more specific
problem. Thanks to have insisted and nice catch :)

Check this image:
http://blog.thepimp.net/misc/39273_out.png

Is it what you expect?



Previous Comments:


[2006-10-28 14:43:21] seth at pricepages dot org

translucide (French) = translucent (English)

Sorry, that confused me for a bit.

"Boolean transparency" means that the pixel is either fully 
transparent, or fully opaque. Never partially transparent.

The area outside of the line is fine, it should be 
transparent and it is in your image. This is correct.

What is suffering from "boolean transparency" are the edges 
of the line. For example:

In your example script, one alpha value was 63, and the 
other was 127. In your output PNG, those values have been 
changed to 0 and 127.

I should mention that if you are using Microsoft's Internet 
Explorer version 6 or less, a PNG image will display with 
boolean transparency due to a bug in the browser. So you 
won't be able to see the difference. Use FireFox.



[2006-10-28 14:19:46] [EMAIL PROTECTED]

Pardon? What is a boolean transparency?

Please understand these three things:
- The transparent color is one *color*, an index for palette  based
image or 32bits value for truecolor images. It defines which color is
used as the *background* color (like white is   the background color of
a white paper).

- The *alpha* channel of a pixel defines how translucide the pixel has
to be. It has nothing to do with the transparent color.

- Your image has *no* transparent color but many pixels with various
*alpha* levels.

Load the result images in your favourite paint programs to see what I
mean. The area outside the line is translucide, it is due to the alpha
channel.




[2006-10-28 14:11:56] seth at pricepages dot org

But that has one of the bugs that I pointed out: boolean 
transparency. The original doesn't have that problem.



[2006-10-28 14:04:59] [EMAIL PROTECTED]

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png






[2006-10-28 13:15:45] seth at pricepages dot org

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39273

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


#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread seth at pricepages dot org
 ID:   39273
 User updated by:  seth at pricepages dot org
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

translucide (French) = translucent (English)

Sorry, that confused me for a bit.

"Boolean transparency" means that the pixel is either fully 
transparent, or fully opaque. Never partially transparent.

The area outside of the line is fine, it should be 
transparent and it is in your image. This is correct.

What is suffering from "boolean transparency" are the edges 
of the line. For example:

In your example script, one alpha value was 63, and the 
other was 127. In your output PNG, those values have been 
changed to 0 and 127.

I should mention that if you are using Microsoft's Internet 
Explorer version 6 or less, a PNG image will display with 
boolean transparency due to a bug in the browser. So you 
won't be able to see the difference. Use FireFox.


Previous Comments:


[2006-10-28 14:19:46] [EMAIL PROTECTED]

Pardon? What is a boolean transparency?

Please understand these three things:
- The transparent color is one *color*, an index for palette  based
image or 32bits value for truecolor images. It defines which color is
used as the *background* color (like white is   the background color of
a white paper).

- The *alpha* channel of a pixel defines how translucide the pixel has
to be. It has nothing to do with the transparent color.

- Your image has *no* transparent color but many pixels with various
*alpha* levels.

Load the result images in your favourite paint programs to see what I
mean. The area outside the line is translucide, it is due to the alpha
channel.




[2006-10-28 14:11:56] seth at pricepages dot org

But that has one of the bugs that I pointed out: boolean 
transparency. The original doesn't have that problem.



[2006-10-28 14:04:59] [EMAIL PROTECTED]

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png






[2006-10-28 13:15:45] seth at pricepages dot org

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.



[2006-10-28 10:49:54] [EMAIL PROTECTED]

"I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other."

You are not aware that your image is *NOT* fully black.

Background color (the transparent color) is not the same than a color
with a ALPHA component. Please run the code I gave you, read the
results (like the values of the channels in these two pixels, or any
other).





The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39273

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


#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread pajoye
 ID:   39273
 Updated by:   [EMAIL PROTECTED]
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

Pardon? What is a boolean transparency?

Please understand these three things:
- The transparent color is one *color*, an index for palette  based
image or 32bits value for truecolor images. It defines which color is
used as the *background* color (like white is   the background color of
a white paper).

- The *alpha* channel of a pixel defines how translucide the pixel has
to be. It has nothing to do with the transparent color.

- Your image has *no* transparent color but many pixels with various
*alpha* levels.

Load the result images in your favourite paint programs to see what I
mean. The area outside the line is translucide, it is due to the alpha
channel.



Previous Comments:


[2006-10-28 14:11:56] seth at pricepages dot org

But that has one of the bugs that I pointed out: boolean 
transparency. The original doesn't have that problem.



[2006-10-28 14:04:59] [EMAIL PROTECTED]

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png






[2006-10-28 13:15:45] seth at pricepages dot org

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.



[2006-10-28 10:49:54] [EMAIL PROTECTED]

"I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other."

You are not aware that your image is *NOT* fully black.

Background color (the transparent color) is not the same than a color
with a ALPHA component. Please run the code I gave you, read the
results (like the values of the channels in these two pixels, or any
other).





[2006-10-27 17:22:07] seth at pricepages dot org

I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other.

Well, I went in and fixed it myself. The problem was in the 
function gdImageGetTrueColorPixel(). It assumed that palette 
images always have binary transparency, with a correct value 
in im->transparent. Because my source image didn't have a 
correct value in im->transparent, it was always marked as 
opaque.

This line:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : 
gdAlphaOpaque);

Needs to be changed to:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : im->alpha
[p]);

Making this patch also fixes the same bug in 
imagecopyresampled(), and who knows what else.


Although, I would recommend using gdTrueColorAlpha() at the 
appropriate point(s) in gdImageCopyResized() instead of 
gdImageGetTrueColorPixel(). This would eliminate an extra 
function call, branch, and color lookup.



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39273

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


#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread seth at pricepages dot org
 ID:   39273
 User updated by:  seth at pricepages dot org
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

But that has one of the bugs that I pointed out: boolean 
transparency. The original doesn't have that problem.


Previous Comments:


[2006-10-28 14:04:59] [EMAIL PROTECTED]

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png






[2006-10-28 13:15:45] seth at pricepages dot org

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.



[2006-10-28 10:49:54] [EMAIL PROTECTED]

"I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other."

You are not aware that your image is *NOT* fully black.

Background color (the transparent color) is not the same than a color
with a ALPHA component. Please run the code I gave you, read the
results (like the values of the channels in these two pixels, or any
other).





[2006-10-27 17:22:07] seth at pricepages dot org

I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other.

Well, I went in and fixed it myself. The problem was in the 
function gdImageGetTrueColorPixel(). It assumed that palette 
images always have binary transparency, with a correct value 
in im->transparent. Because my source image didn't have a 
correct value in im->transparent, it was always marked as 
opaque.

This line:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : 
gdAlphaOpaque);

Needs to be changed to:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : im->alpha
[p]);

Making this patch also fixes the same bug in 
imagecopyresampled(), and who knows what else.


Although, I would recommend using gdTrueColorAlpha() at the 
appropriate point(s) in gdImageCopyResized() instead of 
gdImageGetTrueColorPixel(). This would eliminate an extra 
function call, branch, and color lookup.



[2006-10-27 14:01:12] [EMAIL PROTECTED]

There is nothing wrong in imagecopyresize (or imagecopy).

The problem you have is the misunderstanding of what is the background
color, the alpha channel and alpha blending.

Your original image has many black colors, one is transparent (what you
consider as background), and the other with various transparency
levels.
Try the code below, it will explain you what is your image and how it
works.
http://bugs.php.net/39273

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


#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread pajoye
 ID:   39273
 Updated by:   [EMAIL PROTECTED]
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png





Previous Comments:


[2006-10-28 13:15:45] seth at pricepages dot org

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.



[2006-10-28 10:49:54] [EMAIL PROTECTED]

"I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other."

You are not aware that your image is *NOT* fully black.

Background color (the transparent color) is not the same than a color
with a ALPHA component. Please run the code I gave you, read the
results (like the values of the channels in these two pixels, or any
other).





[2006-10-27 17:22:07] seth at pricepages dot org

I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other.

Well, I went in and fixed it myself. The problem was in the 
function gdImageGetTrueColorPixel(). It assumed that palette 
images always have binary transparency, with a correct value 
in im->transparent. Because my source image didn't have a 
correct value in im->transparent, it was always marked as 
opaque.

This line:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : 
gdAlphaOpaque);

Needs to be changed to:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : im->alpha
[p]);

Making this patch also fixes the same bug in 
imagecopyresampled(), and who knows what else.


Although, I would recommend using gdTrueColorAlpha() at the 
appropriate point(s) in gdImageCopyResized() instead of 
gdImageGetTrueColorPixel(). This would eliminate an extra 
function call, branch, and color lookup.



[2006-10-27 14:01:12] [EMAIL PROTECTED]

There is nothing wrong in imagecopyresize (or imagecopy).

The problem you have is the misunderstanding of what is the background
color, the alpha channel and alpha blending.

Your original image has many black colors, one is transparent (what you
consider as background), and the other with various transparency
levels.
Try the code below, it will explain you what is your image and how it
works.
http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip





The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39273

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


#39273 [Bgs]: imagecopyresized() not compatable with alpha channel

2006-10-28 Thread seth at pricepages dot org
 ID:   39273
 User updated by:  seth at pricepages dot org
 Reported By:  seth at pricepages dot org
 Status:   Bogus
 Bug Type: GD related
 Operating System: Mac 10.4
 PHP Version:  5.1.6
 Assigned To:  pajoye
 New Comment:

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.


Previous Comments:


[2006-10-28 10:49:54] [EMAIL PROTECTED]

"I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other."

You are not aware that your image is *NOT* fully black.

Background color (the transparent color) is not the same than a color
with a ALPHA component. Please run the code I gave you, read the
results (like the values of the channels in these two pixels, or any
other).





[2006-10-27 17:22:07] seth at pricepages dot org

I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other.

Well, I went in and fixed it myself. The problem was in the 
function gdImageGetTrueColorPixel(). It assumed that palette 
images always have binary transparency, with a correct value 
in im->transparent. Because my source image didn't have a 
correct value in im->transparent, it was always marked as 
opaque.

This line:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : 
gdAlphaOpaque);

Needs to be changed to:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : im->alpha
[p]);

Making this patch also fixes the same bug in 
imagecopyresampled(), and who knows what else.


Although, I would recommend using gdTrueColorAlpha() at the 
appropriate point(s) in gdImageCopyResized() instead of 
gdImageGetTrueColorPixel(). This would eliminate an extra 
function call, branch, and color lookup.



[2006-10-27 14:01:12] [EMAIL PROTECTED]

There is nothing wrong in imagecopyresize (or imagecopy).

The problem you have is the misunderstanding of what is the background
color, the alpha channel and alpha blending.

Your original image has many black colors, one is transparent (what you
consider as background), and the other with various transparency
levels.
Try the code below, it will explain you what is your image and how it
works.
http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip





[2006-10-27 04:17:23] seth at pricepages dot org

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:
---
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 this bug report at http://bugs.php.net/?id=39273&edit=1