PHP | imagecolorclosesthwb() Function Last Updated : 23 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The imagecolorclosesthwb() function is an inbuilt function in PHP which is used to get the index of the color hue, white and blackness in the given image. This function returns an integer value with the index of the color which contains the hue, white and blackness nearest the given color. Syntax: int imagecolorclosesthwb ( $image, $red, $green, $blue ) Parameters: This function accepts four parameters as mentioned above and described below: $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image. $red: This parameter is used to set value of red color component. $green: This parameter is used to set value of green color component. $blue: This parameter is used to set value of blue color component. Return Value: This function returns an integer value with the index of the color hue, white and blackness nearest the given color in the image. Below programs illustrate the imagecolorclosesthwb() function in PHP. Program 1: php <?php // Create new image from given URL $image = imagecreatefromgif( 'https://media.geeksforgeeks.org/wp-content/uploads/animateImages.gif'); // Display the index of color echo 'Hue White and Blackness closest color index: ' . imagecolorclosesthwb($image, 5, 165, 10); imagedestroy($image); ?> Output: Hue White and Blackness closest color index: 42 Program 2: php <?php // Create new image from given URL $image = imagecreatefromgif( 'https://media.geeksforgeeks.org/wp-content/uploads/animateImages.gif'); // Array contains rgb color value $color = array( array(7, 150, 0), array(53, 190, 255), array(255, 165, 54) ); // Loop to find closest HWB color foreach($color as $id => $rgb) { echo 'Hue White and Blackness closest color index: ' . imagecolorclosesthwb($image, $rgb[0], $rgb[1], $rgb[2]) . "<br>"; } imagedestroy($image); ?> Output: Hue White and Blackness closest color index: 42 Hue White and Blackness closest color index: 101 Hue White and Blackness closest color index: 186 Related Articles: PHP | imagearc() Function PHP | imagesy() Function PHP | imageellipse() Function Reference: http://php.net/manual/en/function.imagecolorclosesthwb.php Comment More infoAdvertise with us Next Article PHP | imagecolorclosesthwb() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP PHP-function Practice Tags : Misc Similar Reads PHP | imagecolorclosest() Function The imagecolorclosest() function is an inbuilt function in PHP which is used to get the index of the closest color in the given image. This function returns the index of the color in the palette of the image which is closest to the specified RGB value. Syntax: int imagecolorclosest( $image, $red, $g 2 min read PHP | imagecolorclosestalpha() Function The imagecolorclosestalpha() function is an inbuilt function in PHP which is used to get the index of closest color with alpha value in the given image. This function returns the index of the color in the palette of the image which is closest to the specified RGB value and alpha level. The alpha val 2 min read PHP | imagecolorset() Function The imagecolorset() function is an inbuilt function in PHP which is used to set the color for the specified palette index. It is used to specify the index in the palette to the specified color. To perform the actual flood-fill, it is useful to create the flood-fill-like effects in palleted images wi 2 min read PHP | imagecolorat() function The imagecolorat() function is an inbuilt function in PHP which is used to get the index of the color of the pixel. This function returns the pixel value at the specified location.Syntax:Â Â int imagecolorat( $image, $x, $y ) Parameters: This function accepts three parameters as mentioned above and d 2 min read PHP | imagecolormatch() Function The imagecolormatch() function is an inbuilt function in PHP which is used to make the color of palette version of an image more closely match the true color version. This function returns true on success or false on failure. Syntax: bool imagecolormatch ( $image1, $image2 ) Parameters: This functio 2 min read Like