MetaData throwing errors

Created on 22 March 2024, 9 months ago

Problem/Motivation

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.

Proposed resolution

A patch is created to allow to filter out all the values that do not contain a pipe sign, to be able to continue.

Remaining tasks

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.

🐛 Bug report
Status

Needs review

Version

4.0

Component

Code

Created by

🇧🇪Belgium hoebekewim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024