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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [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: Tue Dec 10 00:01:28 2024 UTC