exec() call to convert in MediaThumbnailJp2.php does not throw ImagickException

Created on 19 March 2024, 9 months ago

Problem/Motivation

It looks as if MediaThumbnailJp2.php initially used ImageMagick to create the thumbnail from the JP2 as there is code there to catch an ImagickException. The current code uses ImageMagick's convert via an exec() call, but still tries to catch the ImagickException. exec() will never trigger that exception.

Steps to reproduce

The current code doesn't seem to really pose a problem, but it also doesn't properly capture potential errors.

Proposed resolution

The return value from exec() should be used to determine if the command failed rather then the try/catch method that is in use now.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada g011um Saskatoon

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

Merge Requests

Comments & Activities

  • Issue created by @g011um
  • 🇨🇦Canada g011um Saskatoon

    I think replacing lines 40-48 in src/Plugin/MediaThumbnail/MediaThumbnailJp2.php with something like the following will address the issue. I'll see if I can create a fork and merge request with this change.

        // Convert the JP2 to a thumbnail JPEG
        $output=null;
        $retval=null;
        $cmd = "convert " . $path . " -resize " . $width . "x" . $width . " /tmp/" . $filename . ".jpg 2>&1";
        exec($cmd, $output, $retval);
        if ($retval !== 0)  {
          $this->logger->warning($output);
          return NULL;
        }
    
Production build 0.71.5 2024