PHP | imagecolorexact() Function Last Updated : 23 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The imagecolorexact() function is an inbuilt function in PHP which is used to get the index of specified color in the palette of the image. In created image files only used colors in the image are resolved. Colors present only in the palette are not resolved. Syntax: int imagecolorexact ( $image, $red, $green, $blue ) Parameters: This function accepts four parameters as mentioned above and described below: $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image. $red: This parameter is used to set value of red color component. $green: This parameter is used to set value of green color component. $blue: This parameter is used to set value of blue color component. Return Value: This function returns the index of the specified color in the palette on success, or -1 if the color does not exist. Below programs illustrate the imagecolorexact() function in PHP. Program 1: php <?php // Set the image into variable $image = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/imagecolor1.png'); // Create an array containing colors and image $colors = Array(); $colors[] = imagecolorexact($image, 10, 15, 20); $colors[] = imagecolorexact($image, 30, 180, 70); $colors[] = imagecolorexact($image, 12, 55, 25); $colors[] = imagecolorexact($image, 154, 25, 52); print_r($colors); // Free from memory imagedestroy($image); ?> Output: Array ( [0] => 659220 [1] => 2012230 [2] => 800537 [3] => 10098996 ) Program 2: php <?php // Set the image into variable $image = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/imagecolor1.png'); // Create an array containing colors and image $colors = Array( $colors[] = imagecolorexact($image, 0, 153, 0), $colors[] = imagecolorexact($image, 0, 0, 0), $colors[] = imagecolorexact($image, 255, 255, 255), $colors[] = imagecolorexact($image, 100, 100, 52) ); print_r($colors); // Free from memory imagedestroy($image); ?> Output: Array ( [0] => 39168 [1] => 0 [2] => 16777215 [3] => 6579252 ) Related Articles: PHP | imagearc() Function PHP | imagefilledellipse() Function PHP | imageellipse() Function Reference: http://php.net/manual/en/function.imagecolorexact.php Comment More infoAdvertise with us Next Article PHP | imagecolorexact() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | imagecolorat() function The imagecolorat() function is an inbuilt function in PHP which is used to get the index of the color of the pixel. This function returns the pixel value at the specified location.Syntax:Â Â int imagecolorat( $image, $x, $y ) Parameters: This function accepts three parameters as mentioned above and d 2 min read PHP | imagecolorset() Function The imagecolorset() function is an inbuilt function in PHP which is used to set the color for the specified palette index. It is used to specify the index in the palette to the specified color. To perform the actual flood-fill, it is useful to create the flood-fill-like effects in palleted images wi 2 min read PHP | imagecolorexactalpha() Function The imagecolorexactalpha() function is an inbuilt function in PHP which is used to get the index of the specified color with alpha value. This function returns the index of the specified color and alpha value (RGBA value) in the palette of the image. Syntax: int imagecolorexactalpha ( $image, $red, 2 min read PHP | imagecolordeallocate() Function The imagecolordeallocate() function is an inbuilt function in PHP which is used to de-allocate a color created by imagecolorallocate() or imagecolorallocatealpha() function for an image. Syntax: bool imagecolordeallocate( $image, $color ) Parameters: This function accepts two parameters as mentioned 2 min read PHP | imagecolormatch() Function The imagecolormatch() function is an inbuilt function in PHP which is used to make the color of palette version of an image more closely match the true color version. This function returns true on success or false on failure. Syntax: bool imagecolormatch ( $image1, $image2 ) Parameters: This functio 2 min read Like