|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53580 During resize gdImageCopyResampled cause colors change
Submitted: 2010-12-20 09:45 UTC Modified: 2021-08-25 13:40 UTC
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: chupakabr at gmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 5.2.16 OS: Windows, Ubuntu, CentOS, any?
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: chupakabr at gmail dot com
New email:
PHP Version: OS:


 [2010-12-20 09:45 UTC] chupakabr at gmail dot com
To test resize image containing solid white background. After resize pixels with 
color different from #FFFFFF will appear.
Probable cause:
gdImageSetPixel parameters (red, green, blue, alpha) are casted to int in 
gdImageCopyResampled which cause them to floor so 254.9999999 became 254 instead 
of 255.
Issues seem to be related:


gd.c (last revision 2010-12-21 20:29 UTC by chupakabr at gmail dot com)
Round (last revision 2010-12-20 21:31 UTC by chupakabr at gmail dot com)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-29 18:38 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2015-07-20 14:02 UTC]
IMHO it makes sense to apply rounding (instead of truncation) in
this case, but we might need a fallback for lround() for older
compilers. And interestingly, some quick tests (script from bug
#41820) on Win7/VC14 cause all pixels to be rounded to 0x636363.
Still better than having two colors, but weird.
 [2016-08-21 19:32 UTC]
-Status: Assigned +Status: Suspended -Assigned To: pajoye +Assigned To: cmb
 [2016-08-21 19:33 UTC]
This bug has already been reported as
<>, so I'm suspending this
 [2017-08-16 16:28 UTC]
-Assigned To: cmb +Assigned To:
 [2021-08-25 12:02 UTC]
-Status: Suspended +Status: Open
 [2021-08-25 12:02 UTC]
The issue has been fixed upstream (not yet released, though), so
it may be ported.
 [2021-08-25 13:40 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-08-25 13:41 UTC]
The following pull request has been associated:

Patch Name: Fix #53580: During resize gdImageCopyResampled cause colors change
On GitHub:
 [2021-08-26 16:45 UTC]
Automatic comment on behalf of cmb69
Log: Fix #53580: During resize gdImageCopyResampled cause colors change
 [2021-08-26 16:45 UTC]
-Status: Verified +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 03:01:28 2024 UTC