Skip to content

Instantly share code, notes, and snippets.

@deathlyfrantic
Last active August 8, 2017 14:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deathlyfrantic/3a02a23f5181e384055a to your computer and use it in GitHub Desktop.
Save deathlyfrantic/3a02a23f5181e384055a to your computer and use it in GitHub Desktop.
get useful imagemagick colorspace constants from getImageColorspace() as opposed to mystery integers
<?php
$reflection = new \ReflectionClass("\Imagick");
$colorspaces = array_flip(
array_filter(
$reflection->getConstants(),
function ($k) {
return mb_strpos($k, "COLORSPACE") !== false;
},
ARRAY_FILTER_USE_KEY
)
);
// print_r($colorspaces); // if you want a list uncomment this
$image = new \Imagick($path);
echo $colorspaces[$image->getImageColorspace()];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment