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 V vijay_raj Follow 0 Improve V vijay_raj Follow 0 Improve Article Tags : Misc Web Technologies PHP PHP-function Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like