Grafika\Imagick\Editor::rotate PHP Method

rotate() public method

Rotate an image counter-clockwise.
public rotate ( Image &$image, integer $angle, Color | null $color = null ) : Grafika\EditorInterface
$image Image
$angle integer The angle in degrees.
$color Grafika\Color | null The Color object containing the background color.
return Grafika\EditorInterface An instance of image editor.
    public function rotate(&$image, $angle, $color = null)
    {
        if ($image->isAnimated()) {
            // Ignore animated GIF for now
            return $this;
        }
        $color = $color !== null ? $color : new Color('#000000');
        list($r, $g, $b, $alpha) = $color->getRgba();
        $image->getCore()->rotateImage(new \ImagickPixel("rgba({$r}, {$g}, {$b}, {$alpha})"), $angle * -1);
        return $this;
    }