php.net |  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: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 7.0.22 OS: *
Private report: No CVE-ID: None
 [2017-08-27 11:32 UTC] cmb@php.net
Description:
------------
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] <https://github.com/libgd/libgd/issues/386>

Test script:
---------------
<?php

$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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-27 11:37 UTC] cmb@php.net
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2017-08-27 12:20 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=499f5480f1a9b3063097b53592c37329c1d5f6f8
Log: Fixed bug #75124 (gdImageGrayScale() may produce colors)
 [2017-08-27 12:20 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC