The imagecolorexact() function gets the index of the specified color.
Syntax
imagecolorexact ( $img, $red, $green, $blue )
Parameters
img: Image resource created with imagecreatetruecolor().
red: Red color component
green: Green color component
blue: Blue color component
Return
The imagecolorexact() function returns the index of the specified color in the palette, or -1 if the color does not exist.
Example
The following is an example:
<?php $img = imagecreatefrompng('https://www.tutorialspoint.com/assets/videos/courses/67/images/course_67_image.png'); $colors = Array(); $colors[] = imagecolorexact($img, 30, 90, 50); $colors[] = imagecolorexact($img, 80, 120, 100); $colors[] = imagecolorexact($img, 25, 80, 50); print_r($colors); imagedestroy($img); ?>
Output
The following is the output:
Array ( [0] => 1989170 [1] => 5273700 [2] => 1658930 )