Search code examples
phpimagemagickimagickphp-extension

Get info from php extension


I am using php extension imagick. I want to use parts of it based on the condition if the file format is supported. I can see the info's about the extension using ReflextionExtension() like this:

$imagemagick = new ReflectionExtension('imagick');
$imagemagick ->info();

It renders something like this in the browserwindow: enter image description here

How to get the supported formats as an array?

var_dump() and print_r() don't reveal much. This is the result of a var_dump():

object(ReflectionExtension)#1 (1) { ["name"]=> string(7) "imagick" }

I want to add some code inside a logic that is only excecuted if (JP2) is supported. So I need to get the array of formats to check for it.

Thanks


Solution

  • You can grab that list with Imagick::queryFormats('*');.

    As you're looking for JP2 support, than you may be able to call something like this...

    if (!empty(Imagick::queryFormats('JP2'))) {