Imagick::getImageIndex> <Imagick::getImageHeight
Last updated: Fri, 30 Dec 2011

Imagick::getImageHistogram

(PECL imagick 2.0.0)

Imagick::getImageHistogramGets the image histogram

Descrição

array Imagick::getImageHistogram ( void )

Returns the image histogram as an array of ImagickPixel objects.

Valor Retornado

Returns the image histogram as an array of ImagickPixel objects.

Erros

Dispara ImagickException em erro.



User Contributed Notes
Imagick::getImageHistogram
Iddles
20-Jun-2011 08:02
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.

<?php
$image
= new Imagick("thing.png");
$pixels=$image->getImageHistogram();
foreach(
$pixels as $p){
 
$colors = $p->getColor();
 foreach(
$colors as $c){
        print(
"$c\t" );
 }
 print(
"\t:\t" . $p->getColorCount() . "\n" );
}
?>

This will print out something like:

252    250    252    1    :    125
194    156    182    1    :    126
109    18    79    1    :    11440
2    117    162    1    :    12761
255    255    255    1    :    40769

...where the colums are red, green, blue, alpha, followed by the number of times that colour appears in the image.

Imagick::getImageIndex> <Imagick::getImageHeight
Last updated: Fri, 30 Dec 2011