PHP imagecolorclosesthwb - Get the index of the color closest to the specified color in hue, whiteness, and blackness

PHP 图像处理PHP Image Processing

imagecolorclosesthwb — Get the index of the color closest to the specified color in hue, whiteness, and blackness.

Syntax

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

Get the index of the color closest to the given color in hue, whiteness, and blackness.

Note:This function requires GD 2.0.1 or higher (recommended 2.0.28 or higher).

Parameters

  • imageThe image resource returned by an image creation function (such as imagecreatetruecolor()).
  • redThe value of the red component.
  • greenThe value of the green component.
  • blueThe value of the blue component.

Return Value

Returns an integer, the index of the color closest to the given color in hue, whiteness, and blackness.

Example

<?php
$im = imagecreatefromgif('php.gif');

echo 'HWB: ' . imagecolorclosesthwb($im, 116, 115, 152);

imagedestroy($im);
?>

The output of the above example is similar to:

HWB: 33

Related Articles

PHP 图像处理PHP Image Processing

Other Extensions