php8.5
Home/ Manual/ imagick / imagickdraw/ ImagickDraw::rotate

ImagickDraw::rotate

PHP function Edit on GitHub ✎

(PECL imagick 2, PECL imagick 3)

Applies the specified rotation to the current coordinate space

Description

ImagickDraw::rotate(float $degrees): bool

Func

Applies the specified rotation to the current coordinate space.

Parameters

degrees

degrees to rotate.

Return Values

Void

Examples

ImagickDraw::rotate() example

php
<?php
function rotate($strokeColor, $fillColor, $backgroundColor, $fillModifiedColor) {
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setStrokeOpacity(1);
    $draw->setFillColor($fillColor);
    $draw->rectangle(200, 200, 300, 300);
    $draw->setFillColor($fillModifiedColor);
    $draw->rotate(15);
    $draw->rectangle(200, 200, 300, 300);

    $image = new \Imagick();
    $image->newImage(500, 500, $backgroundColor);
    $image->setImageFormat("png");
    $image->drawImage($draw);

    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

Source: reference/imagick/imagickdraw/rotate.xml · from the official PHP manual (php/doc-en)