#41820 [Opn]: Color noise in resized image when using IMAGECOPYRESAMPLED
| From: | pajoye@php.net | Date: | Thu, 28 Jun 2007 09:58:20 +0000 |
| Subject: | #41820 [Opn]: Color noise in resized image when using IMAGECOPYRESAMPLED | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114398@lists.php.net to get a copy of this message | ||
ID: 41820
Updated by: pajoye@php.net
Reported By: richard dot gavenda at rksting dot cz
Status: Open
Bug Type: GD related
Operating System: Windows XP
PHP Version: 5.2.3
Assigned To: pajoye
New Comment:
It is what I said, a rounding issue. I'm not sure yet how to make it
more portable.
Previous Comments:
------------------------------------------------------------------------
[2007-06-28 09:53:41] richard dot gavenda at rksting dot cz
AMD 32, Windows XP, PHP 5.2.3 - bug present
x86 64, Centos 4, PHP 4.3.9 - bug present
x86 32, Fedora Core 5, PHP 5.1.6 - bug present
Source image 800x600 filled with RBG(127,127,127):
target image 800x600 - OK
http://81.200.49.53:25459/resample.php?w=800&h=600&c=127
target image 701x600 - vertical stripes
http://81.200.49.53:25459/resample.php?w=701&h=600&c=127
target image 800x501 - horizontal stripes
http://81.200.49.53:25459/resample.php?w=800&h=501&c=127
target image 701x501 - noise
http://81.200.49.53:25459/resample.php?w=701&h=501&c=127
"When is source image filled with RGB values equal to power of 2
(0,1,2,4,8,16,32,64,128) the noise disappears", this rule i can
reproduce only on AMD 32 architecture. On other platform is noise
present regardless of fill color.
------------------------------------------------------------------------
[2007-06-28 07:29:29] pajoye@php.net
CopyResampled using floating points to calculate the destination color.
It may result to rounding problem. However I cannot reproduce this
problem on my development platforms (x86 32 and 64bit, amd 64).
What's your architecture?
------------------------------------------------------------------------
[2007-06-27 10:08:39] richard dot gavenda at rksting dot cz
Title correction
------------------------------------------------------------------------
[2007-06-27 10:07:40] richard dot gavenda at rksting dot cz
Description:
------------
When resizing an image filled with solid color using
imagecopyresampled, a destination image is not filled with same solid
color, but with noise of two colors. I was tried this with grayscale
images. Second color in noise was exactly same as source color, but with
RGB channels lowered by 1. When the source image was filled with color,
which had RGB channels values equal to power of 2
(0,1,2,4,8,16,32,64,128) the noise disappears.
Reproduce code:
---------------
$im = imagecreatetruecolor(1045,600);
$back = imagecolorallocate($im, 100, 100, 100);
imagefill($im, 0, 0, $back);
$im2 = imagecreatetruecolor(383,220);
imagecopyresampled($im2,$im,0,0,0,0,383,220,1045,600);
imagepng($im2);
Expected result:
----------------
PNG file filled with color 100,100,100(RGB)
Actual result:
--------------
PNG file filled with color noise of 100,100,100(RGB) and 99,99,99(RGB)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41820&edit=1