$imagick = new \Imagick(realpath($imagePath));//Resize the image to be small, otherwise PHP tends to run out of memory //This might lead to bad results for images that are pathologically 'pixelly'$imagick->adaptiveResizeImage(200, 200, true);$histogramElements = $imagick->getImageHistogram();

User Contributed Notes 1 note

Scratched my head for a while trying to figure out why this only returned a list of coloured pixels, and seemingly no colour count. Well it turns out that for some reason, the ImagickPixel class has a "getColorCount" method, which seems a strange place for it but hey.