PHP 中的 imagecolorclosesthwb() 函数

phpserver side programmingprogramming更新于 2025/7/6 9:07:17

imagecolorclosesthwb() 函数获取包含色相、白色和黑色的颜色的索引

语法

imagecolorclosesthwb ( $img, $red, $green, $blue )

参数

  • img:使用 imagecreatetruecolor() 创建图像

  • red:红色成分

  • green:绿色成分

  • blue:蓝色成分

返回

imagecolorclosesthwb() 函数返回一个包含以下索引的整数色相、白度和黑度与给定颜色最接近的颜色。

示例

以下是示例:

<?php
   $img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
   echo 'HWB = '. imagecolorclosesthwb($img, 50, 110, 90);
   imagedestroy($img);
?>

输出

输出结果如下:

HWB = 87

相关文章