#45030 [NoF-Opn]: Destination image alpah channle noise when using imagecopyresampled

2008-05-29 Thread lieyang at yahoo dot com
 ID:   45030
 User updated by:  lieyang at yahoo dot com
 Reported By:  lieyang at yahoo dot com
-Status:   No Feedback
+Status:   Open
 Bug Type: GD related
 Operating System: x86_64 GNU/Linux Kernel 2.6.9-4
 PHP Version:  5.2.6
 Assigned To:  pajoye
 New Comment:

We have verified the fix resolved our problem. Thank you very much! Do
you have any estimate on when the fix will make into the stable branch?


Previous Comments:


[2008-05-26 01:00:04] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to Open.



[2008-05-18 18:12:32] [EMAIL PROTECTED]

Right, there is a alpha values between 0 and 2. This is a little
rounding issue in the interpolation function.

As it is not relevant when you use the full range of the 8bit (7bit in
gd 2.0.x internals), it could cause some troubles when you introduce
more errors while using only 4bits. 

The worst case will end with an error twice bigger than the original
one. That's certainly why you see the little black pixels.

Here is an attempt to minimize the error in the edge of the alpha
values:

http://pierre.libgd.org/patches/bug45030.txt

It should fix non obvious errors like the one you had.





[2008-05-18 16:14:25] lieyang at yahoo dot com

You can see the noise on both my 56x56 image and image generated from
Rasmus's reproducing code sample with resizing from 90x90 to 50x50 (I am
not talking about the anti-aliasing areas :)

GIMP: Tools  Selection Tools  By Color select, click a few spots in
the empty region of the image and you will see the noise being
selected.

Paint.net: use the color select tool and click a few times on the empty
region of the image, some pixels will display the transparency as 2.

(thank you so much for your quick response!)



[2008-05-18 10:29:14] [EMAIL PROTECTED]

The 56x56 image looks perfectly fine to me. I also checked the alpha
values for the translucent areas and they look fine too (full
translucent when they are not near the star anti aliased pixels, as
expected).

To see how is the alpha channel in the result image, please look at
this zoomed version of the alpha channel only:

http://pierre.libgd.org/bugs/45030_alpha_only.png

100% black means opaque and the gray squares are only to show a
background (what would be behind the image). As you can see, there is no
noise in the transparent areas.

Are you sure that there is not a bug in the Motorola display system?
Maybe it does not support semi transparent pixels.



[2008-05-18 03:51:39] lieyang at yahoo dot com

Here are my test source image (png 90x90): http://tinyurl.com/65tdtm
Resized to 56x56 with noise in alpha channel: http://tinyurl.com/6yold7



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/45030

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



#45030 [Fbk-Opn]: Destination image alpah channle noise when using imagecopyresampled

2008-05-18 Thread lieyang at yahoo dot com
 ID:   45030
 User updated by:  lieyang at yahoo dot com
 Reported By:  lieyang at yahoo dot com
-Status:   Feedback
+Status:   Open
 Bug Type: GD related
 Operating System: x86_64 GNU/Linux Kernel 2.6.9-4
 PHP Version:  5.2.6
 Assigned To:  pajoye
 New Comment:

You can see the noise on both my 56x56 image and image generated from
Rasmus's reproducing code sample with resizing from 90x90 to 50x50 (I am
not talking about the anti-aliasing areas :)

GIMP: Tools  Selection Tools  By Color select, click a few spots in
the empty region of the image and you will see the noise being
selected.

Paint.net: use the color select tool and click a few times on the empty
region of the image, some pixels will display the transparency as 2.

(thank you so much for your quick response!)


Previous Comments:


[2008-05-18 10:29:14] [EMAIL PROTECTED]

The 56x56 image looks perfectly fine to me. I also checked the alpha
values for the translucent areas and they look fine too (full
translucent when they are not near the star anti aliased pixels, as
expected).

To see how is the alpha channel in the result image, please look at
this zoomed version of the alpha channel only:

http://pierre.libgd.org/bugs/45030_alpha_only.png

100% black means opaque and the gray squares are only to show a
background (what would be behind the image). As you can see, there is no
noise in the transparent areas.

Are you sure that there is not a bug in the Motorola display system?
Maybe it does not support semi transparent pixels.



[2008-05-18 03:51:39] lieyang at yahoo dot com

Here are my test source image (png 90x90): http://tinyurl.com/65tdtm
Resized to 56x56 with noise in alpha channel: http://tinyurl.com/6yold7



[2008-05-18 03:41:50] lieyang at yahoo dot com

Please try the following with different image sizes and you will see
that the alpha channel has noise.

(I have two original before and after images but can not find the link
to upload them as attachments)

$imageSrc = imagecreatetruecolor(90, 90);
imagealphablending($imageSrc, false);
imagesavealpha($imageSrc, true);
$color = imagecolorallocatealpha($imageSrc, 0, 0, 0, 127);
imagefill($imageSrc, 0, 0, $color);

$imageDst = imagecreatetruecolor(56, 56);
imagealphablending($imageDst, false);
imagesavealpha($imageDst, true);

imagecopyresampled($imageDst,$imageSrc, 0, 0, 0, 0, 56, 56, 90, 90);

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



[2008-05-17 23:11:41] [EMAIL PROTECTED]

We need a better reproducible example here, including the source image.
 When the source image has a perfect alpha channel, I see no noise.  Try
this:

$imageSrc = imagecreatetruecolor(500, 500);
imagealphablending($imageSrc, false);
imagesavealpha($imageSrc, true);
$color = imagecolorallocatealpha($imageSrc, 0, 0, 0, 127);
imagefill($imageSrc, 0, 0, $color);
$imageDst = imagecreatetruecolor(50, 50);
imagealphablending($imageDst, false);
imagesavealpha($imageDst, true);
imagecopyresampled($imageDst,$imageSrc, 0, 0, 0, 0, 50, 50, 500, 500);

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




[2008-05-17 22:52:00] [EMAIL PROTECTED]

In fact yes, I need the source image (what you have in $imageData).
Sorry for the double posts.



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/45030

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



#45030 [NEW]: Destination image alpah channle noise when using imagecopyresampled

2008-05-17 Thread lieyang at yahoo dot com
From: lieyang at yahoo dot com
Operating system: x86_64 GNU/Linux Kernel 2.6.9-4
PHP version:  5.2.6
PHP Bug Type: GD related
Bug description:  Destination image alpah channle noise when using 
imagecopyresampled

Description:

When resizing a 24 bit png image with imagecopyresampled, the destination
image alpha channel contains noise where it should be completely
transparent. When the re-sized image is displayed on Motorola phones with
only 4 levels of transparency, 
the image shows many dark dots.

If we replace imagecopyresampled with imagecopyresized in the following
sample reproduce code, the problem goes away.

Reproduce code:
---
 
$imageSrc = imagecreatefromstring($imageData);

$imageDst = imagecreatetruecolor($width, $height);
imagealphablending($imageDst, false);
$color = imagecolorallocatealpha($imageDst, 0, 0, 0, 127);
imagefill($imageDst, 0, 0, $color);
imagesavealpha($imageDst, true);

imagecopyresampled($imageDst,$imageSrc, $dst_x, $dst_y, $src_x,
$src_y, $dst_w, $dst_h, $src_w, $src_h);

Expected result:

Completely transparent regions should still be completely transparent in
destination image.

Actual result:
--
Destination image alpha channel noise (some pixel values that should be
fully transparent have different value 2).
You can see the noise all over the transparent regions with any graphics
tools (for example, color selection with gimp).


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



#45030 [Fbk-Opn]: Destination image alpah channle noise when using imagecopyresampled

2008-05-17 Thread lieyang at yahoo dot com
 ID:   45030
 User updated by:  lieyang at yahoo dot com
 Reported By:  lieyang at yahoo dot com
-Status:   Feedback
+Status:   Open
 Bug Type: GD related
 Operating System: x86_64 GNU/Linux Kernel 2.6.9-4
 PHP Version:  5.2.6
 Assigned To:  pajoye
 New Comment:

Please try the following with different image sizes and you will see
that the alpha channel has noise.

(I have two original before and after images but can not find the link
to upload them as attachments)

$imageSrc = imagecreatetruecolor(90, 90);
imagealphablending($imageSrc, false);
imagesavealpha($imageSrc, true);
$color = imagecolorallocatealpha($imageSrc, 0, 0, 0, 127);
imagefill($imageSrc, 0, 0, $color);

$imageDst = imagecreatetruecolor(56, 56);
imagealphablending($imageDst, false);
imagesavealpha($imageDst, true);

imagecopyresampled($imageDst,$imageSrc, 0, 0, 0, 0, 56, 56, 90, 90);

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


Previous Comments:


[2008-05-17 23:11:41] [EMAIL PROTECTED]

We need a better reproducible example here, including the source image.
 When the source image has a perfect alpha channel, I see no noise.  Try
this:

$imageSrc = imagecreatetruecolor(500, 500);
imagealphablending($imageSrc, false);
imagesavealpha($imageSrc, true);
$color = imagecolorallocatealpha($imageSrc, 0, 0, 0, 127);
imagefill($imageSrc, 0, 0, $color);
$imageDst = imagecreatetruecolor(50, 50);
imagealphablending($imageDst, false);
imagesavealpha($imageDst, true);
imagecopyresampled($imageDst,$imageSrc, 0, 0, 0, 0, 50, 50, 500, 500);

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




[2008-05-17 22:52:00] [EMAIL PROTECTED]

In fact yes, I need the source image (what you have in $imageData).
Sorry for the double posts.



[2008-05-17 22:48:55] [EMAIL PROTECTED]

no need for src images :-)



[2008-05-17 22:43:05] [EMAIL PROTECTED]

Please provide me the source image and the result you get. You can use
http://bugs.libgd.org as well as you can add attachments to your report.



[2008-05-17 21:43:31] lieyang at yahoo dot com

Description:

When resizing a 24 bit png image with imagecopyresampled, the
destination image alpha channel contains noise where it should be
completely transparent. When the re-sized image is displayed on Motorola
phones with only 4 levels of transparency, 
the image shows many dark dots.

If we replace imagecopyresampled with imagecopyresized in the following
sample reproduce code, the problem goes away.

Reproduce code:
---
 
$imageSrc = imagecreatefromstring($imageData);

$imageDst = imagecreatetruecolor($width, $height);
imagealphablending($imageDst, false);
$color = imagecolorallocatealpha($imageDst, 0, 0, 0, 127);
imagefill($imageDst, 0, 0, $color);
imagesavealpha($imageDst, true);

imagecopyresampled($imageDst,$imageSrc, $dst_x, $dst_y, $src_x,
$src_y, $dst_w, $dst_h, $src_w, $src_h);

Expected result:

Completely transparent regions should still be completely transparent
in destination image.

Actual result:
--
Destination image alpha channel noise (some pixel values that should be
fully transparent have different value 2).
You can see the noise all over the transparent regions with any
graphics tools (for example, color selection with gimp).






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



#45030 [Opn]: Destination image alpah channle noise when using imagecopyresampled

2008-05-17 Thread lieyang at yahoo dot com
 ID:   45030
 User updated by:  lieyang at yahoo dot com
 Reported By:  lieyang at yahoo dot com
 Status:   Open
 Bug Type: GD related
 Operating System: x86_64 GNU/Linux Kernel 2.6.9-4
 PHP Version:  5.2.6
 Assigned To:  pajoye
 New Comment:

Here are my test source image (png 90x90): http://tinyurl.com/65tdtm
Resized to 56x56 with noise in alpha channel: http://tinyurl.com/6yold7


Previous Comments:


[2008-05-18 03:41:50] lieyang at yahoo dot com

Please try the following with different image sizes and you will see
that the alpha channel has noise.

(I have two original before and after images but can not find the link
to upload them as attachments)

$imageSrc = imagecreatetruecolor(90, 90);
imagealphablending($imageSrc, false);
imagesavealpha($imageSrc, true);
$color = imagecolorallocatealpha($imageSrc, 0, 0, 0, 127);
imagefill($imageSrc, 0, 0, $color);

$imageDst = imagecreatetruecolor(56, 56);
imagealphablending($imageDst, false);
imagesavealpha($imageDst, true);

imagecopyresampled($imageDst,$imageSrc, 0, 0, 0, 0, 56, 56, 90, 90);

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



[2008-05-17 23:11:41] [EMAIL PROTECTED]

We need a better reproducible example here, including the source image.
 When the source image has a perfect alpha channel, I see no noise.  Try
this:

$imageSrc = imagecreatetruecolor(500, 500);
imagealphablending($imageSrc, false);
imagesavealpha($imageSrc, true);
$color = imagecolorallocatealpha($imageSrc, 0, 0, 0, 127);
imagefill($imageSrc, 0, 0, $color);
$imageDst = imagecreatetruecolor(50, 50);
imagealphablending($imageDst, false);
imagesavealpha($imageDst, true);
imagecopyresampled($imageDst,$imageSrc, 0, 0, 0, 0, 50, 50, 500, 500);

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




[2008-05-17 22:52:00] [EMAIL PROTECTED]

In fact yes, I need the source image (what you have in $imageData).
Sorry for the double posts.



[2008-05-17 22:48:55] [EMAIL PROTECTED]

no need for src images :-)



[2008-05-17 22:43:05] [EMAIL PROTECTED]

Please provide me the source image and the result you get. You can use
http://bugs.libgd.org as well as you can add attachments to your report.



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/45030

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