php.net |  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
Votes:3
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
 [2010-12-20 09:45 UTC] chupakabr at gmail dot com
Description:
------------
Reproduce:
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:
http://bugs.php.net/bug.php?id=30591
http://bugs.php.net/bug.php?id=41820


Patches

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)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-29 18:38 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2015-07-20 14:02 UTC] cmb@php.net
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] cmb@php.net
-Status: Assigned +Status: Suspended -Assigned To: pajoye +Assigned To: cmb
 [2016-08-21 19:33 UTC] cmb@php.net
This bug has already been reported as
<https://github.com/libgd/libgd/issues/99>, so I'm suspending this
ticket.
 [2017-08-16 16:28 UTC] cmb@php.net
-Assigned To: cmb +Assigned To:
 [2021-08-25 12:02 UTC] cmb@php.net
-Status: Suspended +Status: Open
 [2021-08-25 12:02 UTC] cmb@php.net
The issue has been fixed upstream (not yet released, though), so
it may be ported.
 [2021-08-25 13:40 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-08-25 13:41 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #53580: During resize gdImageCopyResampled cause colors change
On GitHub:  https://github.com/php/php-src/pull/7402
Patch:      https://github.com/php/php-src/pull/7402.patch
 [2021-08-26 16:45 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/526407ca358f87fd12487917117ff9d873849c44
Log: Fix #53580: During resize gdImageCopyResampled cause colors change
 [2021-08-26 16:45 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC