note 104514 added to function.imagick-getimagehistogram
| From: | Iddles at osu1 dot php dot net | Date: | Mon, 20 Jun 2011 11:02:23 +0000 |
| Subject: | note 104514 added to function.imagick-getimagehistogram | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180673@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 109.169.40.147
Probable Submitter: 93.97.186.229
----
Manual Page -- http://www.php.net/manual/en/function.imagick-getimagehistogram.php
Edit -- https://master.php.net/note/edit/104514
Del: integrated -- https://master.php.net/note/delete/104514/integrated
Del: useless -- https://master.php.net/note/delete/104514/useless
Del: bad code -- https://master.php.net/note/delete/104514/bad+code
Del: spam -- https://master.php.net/note/delete/104514/spam
Del: non-english -- https://master.php.net/note/delete/104514/non-english
Del: in docs -- https://master.php.net/note/delete/104514/in+docs
Del: other reasons-- https://master.php.net/note/delete/104514
Reject -- https://master.php.net/note/reject/104514
Search -- https://master.php.net/manage/user-notes.php