
imagecolorclosest() 函数获取与指定颜色最接近的颜色的索引。
语法
imagecolorallocatealpha (img, red, green, blue)
参数
img: 使用imagecreatetruecolor()创建的图像资源。
red: 红色分量
-
green: 绿色分量
立即学习“PHP免费学习笔记(深入)”;
blue: 蓝色分量
返回值
imagecolorclosest()函数返回图像调色板中最接近颜色的索引。
示例
以下是一个示例:
演示
输出
以下是输出结果:
Closest = (44, 118, 140)
Example
让我们看另一个例子,其中我们有不同的图像和颜色组件:
实时演示
输出
以下是输出结果:
Closest = (228, 74, 76)











