|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75124 gdImageGrayScale() may produce colors
Submitted: 2017-08-27 11:32 UTC Modified: 2017-08-27 11:37 UTC
From: Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 7.0.22 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
16 - 2 = ?
Subscribe to this entry?

 [2017-08-27 11:32 UTC]
For ease of reference, I'm forwarding libgd bug #386[1].

TL;DR: gdImageGrayScale() misses to switch to `gdEffectReplace`
alpha blending mode before calling `gdImageSetPixel` which may
result in colored images.

[1] <>

Test script:

$im = imagecreatefrompng(__DIR__ . '/wings.png');
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagepng($im, __DIR__ . '/wings-out.png');

Expected result:
The generated wings-out.png should be a pure grayscale image.

Actual result:
The generated wings-out.png shows faintly purple colors.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-27 11:37 UTC]
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2017-08-27 12:20 UTC]
Automatic comment on behalf of
Log: Fixed bug #75124 (gdImageGrayScale() may produce colors)
 [2017-08-27 12:20 UTC]
-Status: Analyzed +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 05 09:01:27 2024 UTC