Skip to content

Instantly share code, notes, and snippets.

@crishoj
Last active July 22, 2018 16:52
Show Gist options
  • Save crishoj/c9c4a36365cea4612b65216b33238a19 to your computer and use it in GitHub Desktop.
Save crishoj/c9c4a36365cea4612b65216b33238a19 to your computer and use it in GitHub Desktop.
ImageMagick pixel color extraction from CMYK image
##
## Ubuntu Bionic with PHP 7.2.7 and ImageMagick 6.9.7
##
>>> $resource = new Imagick("tests/images/bookcover.jpg")
=> Imagick {#2286}
>>> $resource->getImagePixelColor(20, 20)->getColor(true)
=> [
"r" => 0.0,
"g" => 0.10196078431373,
"b" => 0.82745098039216,
"a" => 1.0,
]
>>> $resource->transformImageColorspace(Imagick::COLORSPACE_RGB)
=> true
>>> $resource->getImagePixelColor(20, 20)->getColor(true)
=> [
"r" => 1.0,
"g" => 0.78353551537346,
"b" => 0.025192645151446,
"a" => 1.0,
]
>>> $resource->transformImageColorspace(Imagick::COLORSPACE_SRGB)
=> true
>>> $resource->getImagePixelColor(20, 20)->getColor(true)
=> [
"r" => 1.0,
"g" => 0.89803921568627,
"b" => 0.17256427862974,
"a" => 1.0,
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment