Computer >> Computer tutorials >  >> Programming >> PHP

imagecolorclosesthwb() function in PHP


The imagecolorclosesthwb() function gets the index of the color which has the hue, white and blackness

Syntax

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

Parameters

  • img: Create image with imagecreatetruecolor()

  • red: Red color component

  • green: Green color component

  • blue: Blue color component

Return

The imagecolorclosesthwb() function returns an integer with the index of the color which has the hue, white and blackness nearest the given color.

Example

The following is an example:

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

Output

The following is the output:

HWB = 87