English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP imagecolorclosest() function gets the index value of the color closest to the specified color

PHP Image Processing

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

Syntax

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

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

The calculation method for the "distance" between the specified color and each color in the palette is to treat the RGB values as coordinates of points in three-dimensional space.

If an image is created from a file, only the colors used in the image will be analyzed. Colors that only appear in the palette will not be analyzed.

Related articles

PHP Image Processing