Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP imagecolorat - Get the Color Index of a Certain Pixel

PHP imagecolorat - Get the Color Index of a Certain Pixel

PHP Image ProcessingPHP Image Processing

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

PHP Image ProcessingPHP Image Processing