Problem/Motivation
Drupal version is 10.2.4, PHP is 8.3.
[warning] imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data
> GDToolkit.php:271
> [warning] imagecreatefrompng(): gd-png error: setjmp returns error condition 3
> GDToolkit.php:271
> [warning] imagecreatefrompng(): "azblob://inline-images/consumer-goods.png" is not a valid PNG file GDToolkit.php:271
> [warning] The image toolkit 'gd' failed processing 'scale' for image 'azblob://inline-images/consumer-goods.png'. Reported error: TypeError - Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage(): Argument #1 ($image) must be of type ?GdImage, false given, called in /var/www/html/localhost/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php on line 284
> [error] Image scale failed using the gd toolkit on azblob://inline-images/consumer-goods.png (image/png, 1319x1022)
> [warning] imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data
> GDToolkit.php:271
> [warning] imagecreatefrompng(): gd-png error: setjmp returns error condition 3
> GDToolkit.php:271
> [warning] imagecreatefrompng(): "azblob://inline-images/consumer-goods.png" is not a valid PNG file GDToolkit.php:271
[error] TypeError: Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage(): Argument #1 ($image) must be of type ?GdImage, false given, called in /var/www/html/localhost/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php on line 284 in Drupal\system\Plugin\ImageToolkit\GDToolkit->setImage() (line 201 of /var/www/html/localhost/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php) #0 /var/www/html/localhost/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php(284): Drupal\system\Plugin\ImageToolkit\GDToolkit->setImage()
Proposed resolution
Add checking for boolean result of the function.
Remaining tasks
Review my PR, give feedback, merge if possible.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3483541.patch | 807 bytes | radheymkumar |
Comments
Comment #2
radheymkumar commentedAttaching initial patch file.
Comment #3
smustgrave commentedFixes should be in MRs vs patches.
Issue summary appears to be incomplete, missing steps to reproduce
Also will need test coverage.
Comment #4
nayanalok commentedHi, I am getting similar error on Drupal 10.4.2 only line numbers are different.
TypeError: Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage(): Argument #1 ($image) must be of type ?GdImage, bool given