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 // Create a new imagickPixel object $imagickPixel = new ImagickPixel( '#d4a62a' ); // Get the HSL $hsl = $imagickPixel ->getHSL(); print ( "<pre>" .print_r( $hsl , true). "</pre>" ); ?> |
Output:
Array ( [hue] => 0.12156862745098 [saturation] => 0.66929133858268 [luminosity] => 0.49803921568627 )
Program 2:
<?php // Create a new imagickPixel object $imagick = new Imagick( // Get the image histogram $histogramElements = $imagick ->getImageHistogram(); // Get the 300th pixel $getPixel = $histogramElements [300]; // Get the HSL $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