imagecolorclosest

(PHP 4, PHP 5, PHP 7, PHP 8)

imagecolorclosest取得與指定的顏色最接近的顏色的索引值

說明

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

返回圖像調色板中與指定的 RGB 值最“接近”的顏色。

指定的顏色與調色板中的每個顏色的“距離”的計算方法是把 RGB 值當成三維空間中點的坐標。

如果從文件創(chuàng)建了圖像,只有圖像中使用了的顏色會被辨析。僅出現在調色板中的顏色不會被辨析。

參見 imagecolorexact()。