Discards all but one of any pixel color. Available since 6.2.9
Extracts all the unique colors from an image, and generates and 1 pixel high, and 1 pixel wide for each color.
Image
Discards all but one of any pixel color. Available since 6.2.9
function uniqueImageColors($imagePath)
{
    $imagick = new \Imagick(realpath($imagePath));
    //Reduce the image to 256 colours nicely.
    $imagick->quantizeImage(256, \Imagick::COLORSPACE_YIQ, 0, false, false);
    $imagick->uniqueImageColors();
    $imagick->scaleimage($imagick->getImageWidth(), $imagick->getImageHeight() * 20);
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}