- Issue created by @hoebekewim
- Status changed to Needs review
9 months ago 11:28am 22 March 2024
Version: ImageMagick 6.9.10-68 Q16 x86_64
When generating images on our project, performing a conversion to WEBP, we've encountered that during the creation of some images, the following errors/warnings were thrown.
Warning : Undefined array key 1 dans Drupal\imagemagick\Plugin\FileMetadata\ImagemagickIdentify->identify() (/web/modules/contrib/imagemagick/src/Plugin/FileMetadata/ImagemagickIdentify.php ligne 208)
TypeError : trim(): Argument #1 ($string) must be of type string, null given dans trim() (ligne 214 de /web/modules/contrib/imagemagick/src/Plugin/FileMetadata/ImagemagickIdentify.php).
The issue occurs because there is additional output which is retrieved when using the identify command:
Decoded /tmp/magick-6050w68DqfhHR9x9. Dimensions: 328 x 450. Now saving...
Saved file /tmp/magick-60508Ys8A13Dlzsu
format:PAM|width:328|height:450|colorspace:sRGB|profiles:|exif_orientation:
As you can see there is a line "Decoded" and "Saved file" inside, which crashes the code later on.
A patch is created to allow to filter out all the values that do not contain a pipe sign, to be able to continue.
It might be required to review this, maybe the original cause can be fixed in a different way, or there is another solution possible than checking on the pipe sign.
Needs review
4.0
Code