Image sharpening produce black images with PHP 7.0 and GD #447

Closed
opened 2026-10-04 23:59:15 +02:00 by adam · 1 comment
Owner

This bug has been reproduced on Centos 6.7 with PHP 7.0.4 and Ubuntu with php 7.0.5, both with GD library.
For example, generation of XXS thumbnails produce black images with default configuration. The problem lies in admin/includes/image.class.php in the get_sharpen_matrix function. Precisely, the normalized matrix will output bad images with the GD imageconvolution function, without throwing errors.
Changing the normalizing code from


for ($i=0; $i<3; $i++)
{
    $line = & $matrix[$i];
    for ($j=0; $j<3; $j++)
    {
      $line[$j] /= $norm;
    }
}

To


for ($i=0; $i<3; $i++)
{
    for ($j=0; $j<3; $j++)
    {
      $matrix[$i][$j] /= $norm;
    }
}

resolve the problem.

This bug has been reproduced on Centos 6.7 with PHP 7.0.4 and Ubuntu with php 7.0.5, both with GD library. For example, generation of XXS thumbnails produce black images with default configuration. The problem lies in admin/includes/image.class.php in the get_sharpen_matrix function. Precisely, the normalized matrix will output bad images with the GD imageconvolution function, without throwing errors. Changing the normalizing code from <pre lang="javascript"><code> for ($i=0; $i<3; $i++) { $line = & $matrix[$i]; for ($j=0; $j<3; $j++) { $line[$j] /= $norm; } } </code></pre> To <pre lang="javascript"><code> for ($i=0; $i<3; $i++) { for ($j=0; $j<3; $j++) { $matrix[$i][$j] /= $norm; } } </code></pre> resolve the problem. <!-- github-sync-id:150477011 -->
adam closed this issue 2026-10-04 23:59:15 +02:00
Author
Owner

I can confirm that this is an old annoying bug, since the app was told to be PHP7 compatible since 2.8.0, and it globally seems to work well with PHP7.

I can confirm that this is an old annoying bug, since the app was told to be PHP7 compatible since 2.8.0, and it globally seems to work well with PHP7. <!-- github-comment-id:265975559 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#447