PHP | imagecolorat() function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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 described below: $image: The imagecreatetruecolor() function is used to create an image in a given size.$x: This parameter is used to hold the x-coordinate of the point.$y: This parameter is used to hold the y-coordinate of the point. Return Value: This function returns the color index (color pixel value) or FALSE on failure.Below program illustrate the imagecolorat() function in PHP.Note: The image given below is used in the following program. Program 1: php <?php // store the image in variable $image = imagecreatefrompng("gfg.png"); // Calculate rgb pixel value at particular point. $rgb = imagecolorat($image, 30, 25); $red = ($rgb >> 16) & 255; $green = ($rgb >> 8) & 255; $blue = $rgb & 255; var_dump($red, $green, $blue); ?> Output: int(34) int(170) int(66) Program 2: php <?php // store the image in variable. $image = imagecreatefrompng("gfg.png"); // Calculate rgb pixel value at particular point. $rgb = imagecolorat($image, 30, 25); // Assign color name and its value. $colors = imagecolorsforindex($image, $rgb); var_dump($colors); ?> Output: array(4) { ["red"]=> int(34) ["green"]=> int(170) ["blue"]=> int(66) ["alpha"]=> int(0) } Reference: https://www.php.net/manual/en/function.imagecolorat.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 | imagecolorexact() Function 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, $r 2 min read PHP | imagecolorexact() Function 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, $r 2 min read PHP | imagecolorexact() Function 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, $r 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 | 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 | 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 Like