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: 2017-08-16 16:28 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:
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
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)

Add a Patch

Pull Requests

Add a Pull Request

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:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jan 17 19:01:26 2019 UTC