This example creates a red color, rotates the hue by 180 degrees and sets the new color.

Original color

r : 230
g : 26
b : 26
a : 1

Rotated color

r : 26
g : 230
b : 230
a : 1
        $output = "This example creates a red color, rotates the hue by 180 degrees and sets the new color.
"; //Create an almost pure red color $color = new \ImagickPixel('rgb(90%, 10%, 10%)'); $originalColor = clone $color; //Get it's HSL values $colorInfo = $color->getHSL(); //Rotate the hue by 180 degrees $newHue = $colorInfo['hue'] + 0.5; if ($newHue > 1) { $newHue = $newHue - 1; } //Set the ImagickPixel to the new color $color->setHSL($newHue, $colorInfo['saturation'], $colorInfo['luminosity']); $output .= "

Original color

"; $colorInfo = $originalColor->getcolor(); foreach ($colorInfo as $key => $value) { $output .= "$key : $value
"; } $output .= "

Rotated color

"; //Check that the new color is blue/green $colorInfo = $color->getcolor(); foreach ($colorInfo as $key => $value) { $output .= "$key : $value
"; } return $output;