WP_Image_Editor_Imagick::rotate PHP Method

rotate() public method

Rotates current image counter-clockwise by $angle.
Since: 3.5.0
public rotate ( float $angle ) : true | WP_Error
$angle float
return true | WP_Error
    public function rotate($angle)
    {
        /**
         * $angle is 360-$angle because Imagick rotates clockwise
         * (GD rotates counter-clockwise)
         */
        try {
            $this->image->rotateImage(new ImagickPixel('none'), 360 - $angle);
            // Since this changes the dimensions of the image, update the size.
            $result = $this->update_size();
            if (is_wp_error($result)) {
                return $result;
            }
            $this->image->setImagePage($this->size['width'], $this->size['height'], 0, 0);
        } catch (Exception $e) {
            return new WP_Error('image_rotate_error', $e->getMessage());
        }
        return true;
    }