PHP | ImagickPixel setHSL() function Last Updated : 02 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The ImagickPixel::setHSL() function is an inbuilt function in PHP which is used to set the color described by the ImagickPixel object using normalized values for hue, saturation and luminosity. Syntax: bool ImagickPixel::setHSL( float $hue, float $saturation, float $luminosity ) Parameters:This function accepts three parameters as mentioned above and described below: $hue: It specifies the normalized value for hue. $saturation: It specifies the normalized value for saturation. $luminosity: It specifies the normalized value for luminosity. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the ImagickPixel::setHSL() function in PHP: Program 1: php <?php // Create a new imagickPixel object $imagickPixel = new ImagickPixel(); // Set the HSL for pixel $imagickPixel->setHSL(0.4, 0.4, 0.4); // Get the HSL of pixel $HSL = $imagickPixel->getHSL(); print("<pre>".print_r($HSL, true)."</pre>"); ?> Output: Array ( [hue] => 0.40000158942082 [saturation] => 0.4000152590219 [luminosity] => 0.4 ) Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Get the pixel iterator to iterate through each pixel $imageIterator = $imagick->getPixelIterator(); // Loop through pixel rows foreach ($imageIterator as $row => $pixels) { // Loop through the pixels in the row foreach ($pixels as $column => $pixel) { // Get the current HSL $HSL = $pixel->getHSL(); // Set the HSL and change only hue $pixel->setHSL(0.6, $HSL['saturation'], $HSL['luminosity']); } // Sync the iterator after each iteration $imageIterator->syncIterator(); } header("Content-Type: image/jpg"); echo $imagick; ?> Output: Reference: https://www.php.net/manual/en/imagickpixel.sethsl.php Comment More infoAdvertise with us Next Article PHP | ImagickPixel setHSL() function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | ImagickPixel setColor() function The ImagickPixel::setColor() function is an inbuilt function in PHP which is used to set the color of the ImagickPixel object. Syntax: bool ImagickPixel::setColor( string $color ) Parameters:This function accepts a single parameter $color which holds the color. Return Value: This function returns TR 1 min read PHP | ImagickPixel setColorValue() function The ImagickPixel::setColorValue() function is an inbuilt function in PHP which is used to set the normalized value of the provided color channel for a given ImagickPixel's color. The normalized value is a floating-point number between 0 and 1. Syntax: bool ImagickPixel::setColorValue( int $color, fl 2 min read PHP | Imagick setSize() Function The Imagick::setSize() function is an inbuilt function in PHP which is used to set the size associated with an imagick object. Syntax: bool Imagick::setSize( int $columns, int $rows ) Parameters: This function accepts two parameters as mentioned above and described below: $columns: It specifies the 1 min read PHP | Imagick setResolution() Function The Imagick::setResolution() function is an inbuilt function in PHP which is used to set the resolution for image. This function doesn't changes the actual resolution of a image but just sets it in the Imagick object before image is read or created, for changing image resolution use setImageResoluti 2 min read PHP | ImagickPixel getHSL() function 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 p 1 min read Like