PHP | Gmagick getimagecolors() Function Last Updated : 17 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The Gmagick::getimagecolors() function is an inbuilt function in PHP which is used to get the number of unique colors in the image. Syntax: int Gmagick::getimagecolors( void ) Parameters:This function doesn’t accept any parameter. Return Value: This function returns an integer value. Exceptions: This function throws GmagickException on error. Used Image: To capture the canvas area Below given programs illustrate the Gmagick::getimagecolors() function in PHP: Program 1: For an image with multiple colors. php <?php // Create a new Gmagick object $gmagick = new Gmagick('geeksforgeeks.png'); // Get the border color $color = $gmagick->getimagecolors(); echo $color; ?> Output: 2955 Program 2: For an image with single color. php <?php // Create a new Gmagick object $gmagick = new Gmagick('singlecolor.png'); // Get the border color $color = $gmagick->getimagecolors(); echo $color; ?> Output: 1 Program 3: For a drawing php <?php // Create a new Gmagick object $gmagick = new Gmagick('geeksforgeeks.png'); // Create a GmagickDraw object $draw = new GmagickDraw(); // Set the color $draw->setFillColor('white'); // Function to draw rectangle $draw->rectangle(0, 0, 800, 400); // Set the fill color $draw->setFillColor('red'); // Set the font size $draw->setfontsize(50); // Annotate a text $draw->annotate(30, 100, 'GeeksforGeeks'); // Use of drawimage function $gmagick->drawImage($draw); // Get the image colors $colors = $gmagick->getimagecolors(); echo $colors; ?> Output: 238 Reference: https://www.php.net/manual/en/gmagick.getimagecolors.php Comment More infoAdvertise with us Next Article PHP | Gmagick getimagecolors() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Gmagick Similar Reads PHP | Imagick getImageColors() Function The Imagick::getImageColors() function is an inbuilt function in PHP which is used to get the number of unique colors in the image. Syntax:  int Imagick::getImageColors( void ) Parameters: This function does not accepts any parameters. Return Value: This function returns an integer value which dete 1 min read PHP | Gmagick getimagecolorspace() Function The Gmagick::getimagecolorspace() function is an inbuilt function in PHP which is used to get the image colorspace. The color space is a mathematical model which describes the range of colors as tuples of numbers, typically as 3 or 4 values are color components(RGB). Syntax: int Gmagick::getimagecol 1 min read PHP | Gmagick getimagecompose() Function The Gmagick::getimagecompose() function is an inbuilt function in PHP which is used to get the composite operator associated with the image. The composite operator decides the method to be used for image composition. The composite operator can be anyone from given COMPOSITE OPERATOR constants. Synta 1 min read PHP | Gmagick getimagemattecolor() Function The Gmagick::getimagemattecolor() function is an inbuilt function in PHP which is used to get the image matte color. Syntax: GmagickPixel Gmagick::getimagemattecolor( void ) Parameters: This function doesnât accept any parameters. Return Value: This function returns a GmagickPixel object containing 1 min read PHP | Imagick getImageColorspace() Function The Imagick::getImageColorspace() function is an inbuilt function in PHP which is used to get the colorspace of the image. The color space is a mathematical model which describes the range of colors as tuples of numbers, typically as 3 or 4 values or color components(RGB). Syntax: int Imagick::getIm 1 min read Like