The imagecolorresolve() function gets the index of the specified color or its closest possible alternative.
Syntax
imagecolorresolve (img , red , green , blue )
Parameters
img: Image created with imagecreatetruecolor() function.
red: The value of red component.
green: The value of green component.
blue: The value of blue component.
Return
The imagecolorresolve() function returns the color index.
Example
The following is an example
<?php $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif'); $colors = array(); $colors[] = imagecolorresolve($img, 120, 0, 190); $colors[] = imagecolorresolve($img, 110, 0, 140); $colors[] = imagecolorresolve($img, 120, 190, 0); print_r($colors); imagedestroy($img); ?>
Output
The following is the output:
Array ( [0] => 128 [1] => 129 [2] => 130 )