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:

 Live Demo

<?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

Updated on: 31-Dec-2019

24 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements