PHP imagecolorat - Get the Color Index of a Certain Pixel
imagecolorat — Gets the color index value of a certain pixel.
Syntax
int imagecolorat ( resource $image , int $x , int $y )
Returns the color index value of the pixel at the specified position in the image specified by image.
If PHP is compiled with GD library 2.0 or higher and the image is a true-color image, this function returns the RGB value of that point as an integer. Use shift plus mask to obtain the red, green, and blue component values.
Example
Get the respective RGB values.
> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
?>
Related Articles
- imagecolorset() Set the color for the specified palette index.
- imagecolorsforindex() Get the color of a certain index.
PHP Image Processing