extra-php-extensions icon indicating copy to clipboard operation
extra-php-extensions copied to clipboard

feat(imagick): make `convert` available in layer

Open annuh opened this issue 1 year ago • 3 comments

Running convert directly does not work.

For example:

exec('convert --version');

triggers this error:

sh: convert: command not found

This PR makes convert available in the Imagick layer.

annuh avatar Jan 17 '24 09:01 annuh

Could you tell me why you need convert?

Nyholm avatar Jan 18 '24 20:01 Nyholm

Friendly ping

Nyholm avatar Feb 20 '24 06:02 Nyholm

I'm sorry for the late reply!

My initial though was, if the Imagick Bref extension includes Ghostscript (gs), why not also include convert. In one of our serverless applications, we used to invoke convert directly, but I didn't realize we could replace this with the PHP Imagick extension. 🙂 For example

-exec("convert compare -metric AE '{$image1}' '{$image2}' NULL:", $output);
-$similarity = (float) $output[0];
+$similarity = (new \Imagick($image1))->compareImages(new \Imagick($image2), \Imagick::METRIC_ABSOLUTEERRORMETRIC)[1];

After these changes, we don't need the imagick binary anymore. But maybe it can be a useful for other use cases? If you think it's not needed, I'll close this PR 🙂

annuh avatar Mar 16 '24 09:03 annuh