PHP | GmagickPixel getcolor() Function Last Updated : 29 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The GmagickPixel::getcolor() function is an inbuilt function in PHP which is used to get the color described by the GmagickPixel object, as a string or an array. If the color has an opacity channel set, this is provided as a fourth value in the list. Syntax: mixed GmagickPixel::getcolor( bool $as_array, bool $normalized_array ) Parameters: This function accepts two parameters as mentioned above and described below: $as_array (Optional): It specifies whether to get value as array. Its default value is FALSE. $normalized_array (Optional): It specifies whether to get normalized array. Its default value is FALSE. Return Value: This function returns a string or an array of color values. Exceptions: This function throws GmagickPixelException on error. Below given programs illustrate the GmagickPixel::getcolor() function in PHP: Program 1 (Getting color as string): php <?php // Create a new GmagickPixel object // using __construct $gmagickPixel = new GmagickPixel('#ccb062'); // Get the color $color = $gmagickPixel->getcolor(); print("<pre>".print_r($color, true)."</pre>"); ?> Output: rgb(52428, 45232, 25186) Program 2 (Getting color as array with normalization): php <?php // Create a new GmagickPixel object // using __construct $gmagickPixel = new GmagickPixel('#ccb062'); // Get the color $color = $gmagickPixel->getcolor(true, true); print("<pre>".print_r($color, true)."</pre>"); ?> Output: Array ( [r] => 0.8 [g] => 0.69019607843137 [b] => 0.3843137254902 ) Program 3 (Getting color as array without normalization): php <?php // Create a new GmagickPixel object // using __construct $gmagickPixel = new GmagickPixel('#ccb062'); // Get the color $color = $gmagickPixel->getcolor(true, false); print("<pre>".print_r($color, true)."</pre>"); ?> Output: Array ( [r] => 204 [g] => 176 [b] => 98 ) Reference: https://www.php.net/manual/en/gmagickpixel.getcolor.php Comment More infoAdvertise with us Next Article PHP | GmagickPixel getcolorcount() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Gmagick Similar Reads PHP | ImagickPixel getColor() Function The ImagickPixel::getColor() function is an inbuilt function in PHP which is used to get the color described by the ImagickPixel object, as an array. If the color has an opacity channel set, this is provided as a fourth value in the list. Keys of the array are r is (red), b is (blue), g is (green) a 2 min read PHP | GmagickPixel getcolorvalue() Function The GmagickPixel::getcolorvalue() function is an inbuilt function in PHP which is used to get the normalized value of the provided color channel for a given GmagickPixel color. The normalized value is a floating-point number between 0 and 1. Syntax: float GmagickPixel::getcolorvalue( int $color ) Pa 2 min read PHP | GmagickPixel getcolorcount() Function The GmagickPixel::getcolorcount() function is an inbuilt function in PHP which is used to get the color count associated with the pixel color. A color count is the number of pixels in the image that have the same color as this GmagickPixel. The getcolorcount() appears to only work for GmagickPixel o 2 min read PHP | ImagickPixel getColorValue() function The ImagickPixel::getColorValue() function is an inbuilt function in PHP which is used to get the normalized value of the provided color channel for a given ImagickPixel's color. The normalized value is a floating-point number between 0 and 1. Syntax: float ImagickPixel::getColorValue( int $color ) 1 min read PHP | ImagickPixel getColorCount() function The ImagickPixel::getColorCount() function is an inbuilt function in PHP which is used to get the color count associated with the pixel color. A color count is the number of pixels in the image that have the same color as this ImagickPixel. getColorCount() appears to only work for ImagickPixel objec 2 min read PHP | ImagickPixel getColorQuantum() Function The ImagickPixel::getColorQuantum() function is an inbuilt function in PHP which is used to get the color of the pixel in an array as Quantum values. This function returns an array with keys r, g, b and an each stands for red, green, blue and alpha/opacity respectively. Quantum value ranges from 0 t 2 min read Like