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

PHP imagecolorclosest - Get the Index of the Color Closest to the Specified Color

PHP imagecolorclosest - Get the Index of the Color Closest to the Specified Color

PHP Image ProcessingPHP Image Processing

imagecolorclosest — Gets the index value of the color closest to the specified color.

Syntax



int imagecolorclosest ( resource $image , int $red , int $green , int $blue )

Returns the color in the image palette that is closest to the specified RGB value.

The "distance" between the specified color and each color in the palette is calculated by treating the RGB values as coordinates of a point in three-dimensional space.

If the image was created from a file, only colors actually used in the image are resolved. Colors that appear only in the palette are not resolved.

Related Articles

PHP Image ProcessingPHP Image Processing