|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66714 imageconvolution processing output inconsistent with previous versions
Submitted: 2014-02-14 19:22 UTC Modified: 2014-04-13 23:08 UTC
Avg. Score:4.5 ± 1.2
Reproduced:15 of 15 (100.0%)
Same Version:15 (100.0%)
Same OS:9 (60.0%)
From: drew dot mclellan at gmail dot com Assigned: stas
Status: Closed Package: GD related
PHP Version: 5.5.9 OS: Linux
Private report: No CVE-ID:
 [2014-02-14 19:22 UTC] drew dot mclellan at gmail dot com
The behaviour of imageconvolution() appears to have changed in PHP 5.5.9. The results are visual, so hard to describe, but the behaviour is significantly different from earlier versions.

The test script is boilerplate code for basic image sharpening, as found all over the web. In PHP 5.5.9 the result is a loss of brightness in the resulting image.

Test script:
$image = imagecreatefromjpeg('/path/to/picture.jpg');
$matrix = array(array(-1, -1, -1), array(-1, 20, -1), array(-1, -1, -1));
$divisor = array_sum(array_map('array_sum', $matrix));
imageconvolution($image, $matrix, $divisor, 0);
echo imagecolorat($image, 0, 0);

Expected result:
The echo'd output (colour reference number at 0,0) should be the same in PHP 5.5.8 and 5.5.9 for the same input image.

Actual result:
The output number is much lower in 5.5.9 than 5.5.8, indicating a darker colour and a loss of brightness. The issue is that the behaviour has changed.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-18 08:16 UTC] chris at lodesys dot com
Seeing the same problem in Windows.

In testing, it appears that the $sharpenMatrix is being ignored by imageconvolution() and a matrix of all 1's is being used instead. This results in a blurred image no matter what values are used for $sharpenMatrix.

I consider this a critical bug as my sites rely on the ability to resize and sharpen images (with imageconvolution). Have had to revert to 5.9.8.
 [2014-02-19 17:57 UTC] brad at bradleyboy dot com
Here's an image to show the visual differences between 5.5.8 and 5.5.9. As Drew notes, it's significant. These tests were run on OS X, but the issue is also present on Linux (and I assume Windows, but do not have a way to test that to confirm). 

In the test, the following matrix was applied:

$matrix = array(array(-1, -1, -1), array(-1, 20, -1), array(-1, -1, -1));
$divisor = array_sum(array_map('array_sum', $matrix));
imageconvolution($image, $matrix, $divisor, 0);

 [2014-02-19 21:28 UTC] brad at bradleyboy dot com
I have limited C knowledge, but this looks like a simple typo in a recent change. Pull request here:
 [2014-02-19 22:12 UTC] chrispmaiden at gmail dot com
I can confirm Brad's findings, it looks like this commit introduced the problem. It's the only change in imageconvolution between the two versions and looks like a simple typo.
 [2014-03-06 18:51 UTC] chris at lodesys dot com
Still seeing this bug in 5.5.10. Cannot upgrade from 5.5.8 until the fix is incorporated.
 [2014-03-06 19:17 UTC] brad at bradleyboy dot com
Not sure why it didn't make it into 5.5.10, but looks like it will be in 5.5.11 according to this:
 [2014-04-13 23:08 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2014-04-13 23:08 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

Looks like 5.5.11 fixed it. Please reopen if still happens on current 5.5.
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue May 23 14:01:44 2017 UTC