|  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: 2017-08-16 16:28 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:
Status: Suspended Package: GD related
PHP Version: 5.2.16 OS: Windows, Ubuntu, CentOS, any?
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

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:
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Oct 26 22:01:23 2020 UTC