Get ImageMagick version with PHP
Knowing what version of ImageMagick is usually important if you're going to be shelling to it to perform tasks. For me it was the --sepia-tone option that was added in either 6.2.1 or 6.2.2. Prior to that, using that option caused the conversion to fail.
The following function will return the numeric version of ImageMagick you have installed.
-
function ImageMagick_version()
-
{
-
$convert_path = '/usr/bin/convert --version';
-
return $arr_return[1];
-
}
Of course you'll have to make sure that $convert_path points to the correct path for your ImageMagick command and that you have permissions to run the command.




Ryan on August 23rd, 2006 at 8:47 pm
It seems that this may not work with older versions of ImageMagick. I’ve had a few cases where this function returned an empty string. In those cases I’ve been unable to determine the ImageMagick version, so I’m just assuming it’s an older version issue. I’m thinking a version number like 5.5 may cause a similar problem because of the regex used.