PHP | ImagickPixel getHSL() function
Last Updated :
23 Jan, 2020
The ImagickPixel::getHSL() function is an inbuilt function in PHP which is used to get the normalized HSL color described by the ImagickPixel object, with each being floating-point numbers between 0 and 1. HSL stands for hue, saturation, and luminosity. In general, hue decides what color is of the pixel whereas saturation decides the intensity of color further luminosity decides whether the color is dull or bright.
Syntax:
array ImagickPixel::getHSL( void )
Parameters:This function doesn’t accept any parameter.
Return Value: This function returns an array value containing the HSL values.
Exceptions: This function throws ImagickException on error.
Below given programs illustrate the ImagickPixel::getHSL() function in PHP:
Program 1:
<?php
$imagickPixel = new ImagickPixel( '#d4a62a' );
$hsl = $imagickPixel ->getHSL();
print ( "<pre>" .print_r( $hsl , true). "</pre>" );
?>
|
Output:
Array
(
[hue] => 0.12156862745098
[saturation] => 0.66929133858268
[luminosity] => 0.49803921568627
)
Program 2:
<?php
$imagick = new Imagick(
$histogramElements = $imagick ->getImageHistogram();
$getPixel = $histogramElements [300];
$hsl = $getPixel ->getHSL();
print ( "<pre>" .print_r( $hsl , true). "</pre>" );
?>
|
Output:
Array
(
[hue] => 0.54583333333333
[saturation] => 0.29850746268657
[luminosity] => 0.26274509803922
)
Reference: https://www.php.net/manual/en/imagickpixel.gethsl.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...