<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Returns the color count associated with this color</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="imagickpixel.getcolorasstring.html">ImagickPixel::getColorAsString</a></div> <div class="next" style="text-align: right; float: right;"><a href="imagickpixel.getcolorquantum.html">ImagickPixel::getColorQuantum</a></div> <div class="up"><a href="class.imagickpixel.html">ImagickPixel</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="imagickpixel.getcolorcount" class="refentry"> <div class="refnamediv"> <h1 class="refname">ImagickPixel::getColorCount</h1> <p class="verinfo">(PECL imagick 2.0.0)</p><p class="refpurpose"><span class="refname">ImagickPixel::getColorCount</span> — <span class="dc-title">Returns the color count associated with this color</span></p> </div> <div class="refsect1 description" id="refsect1-imagickpixel.getcolorcount-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>ImagickPixel::getColorCount</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Returns the color count associated with this color. </p> <p class="para">The color count is the number of pixels in the image that have the same color as this ImagickPixel. </p> <p class="para"> ImagickPixel::getColorCount appears to only work for ImagickPixel objects created through Imagick::getImageHistogram() </p> </div> <div class="refsect1 returnvalues" id="refsect1-imagickpixel.getcolorcount-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the color count as an integer on success, throws ImagickPixelException on failure. </p> </div> <div class="refsect1 examples" id="refsect1-imagickpixel.getcolorcount-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4118"> <p><strong>Example #1 ImagickPixel <span class="function"><strong>getColorCount()</strong></span></strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /> $imagick </span><span style="color: #007700">= new \</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">();<br /> </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">newPseudoImage</span><span style="color: #007700">(</span><span style="color: #0000BB">640</span><span style="color: #007700">, </span><span style="color: #0000BB">480</span><span style="color: #007700">, </span><span style="color: #DD0000">"magick:logo"</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$histogramElements </span><span style="color: #007700">= </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">getImageHistogram</span><span style="color: #007700">();<br /> </span><span style="color: #0000BB">$lastColor </span><span style="color: #007700">= </span><span style="color: #0000BB">array_pop</span><span style="color: #007700">(</span><span style="color: #0000BB">$histogramElements</span><span style="color: #007700">);<br /> echo </span><span style="color: #DD0000">"Last pixel color count is: "</span><span style="color: #007700">.</span><span style="color: #0000BB">$lastColor</span><span style="color: #007700">-></span><span style="color: #0000BB">getColorCount</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p> The output for this will be similar to: </p></div> <div class="example-contents screen"> <div class="cdata"><pre> Last pixel color count is: 256244 </pre></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="imagickpixel.getcolorasstring.html">ImagickPixel::getColorAsString</a></div> <div class="next" style="text-align: right; float: right;"><a href="imagickpixel.getcolorquantum.html">ImagickPixel::getColorQuantum</a></div> <div class="up"><a href="class.imagickpixel.html">ImagickPixel</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>