Wednesday, August 27, 2025
HomeLanguagesPHP | Imagick rotateImage() Function

PHP | Imagick rotateImage() Function

The Imagick::rotateImage() function is an inbuilt function in PHP which is used to rotate an image by a given angle and the empty spaces filled with given color.

Syntax:

bool Imagick::rotateImage( $background, $degrees )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $background: This parameter is used to set the background color of image. Datatype of this can be string as well as float.
  • $degrees: This parameter is used to set the angle by which the image is rotated. The rotation angle is interpreted as clockwise.

Return Value: This function returns True on success.

Below program illustrate Imagick::rotateImage() function in PHP:
Original Image:

Program:




<?php
  
// require_once('path/vendor/autoload.php');
  
// Create a new imagick object
  
$image = new Imagick(
  
// Function to rotate an Image
$image->rotateimage('green', 25);
  
header("Content-Type: image/jpg");
  
// Display the output
echo $image->getImageBlob();
?>


Output:

Related Articles:

Reference: http://php.net/manual/en/imagick.rotateimage.php

RELATED ARTICLES

Most Popular

Dominic
32236 POSTS0 COMMENTS
Milvus
80 POSTS0 COMMENTS
Nango Kala
6609 POSTS0 COMMENTS
Nicole Veronica
11779 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11828 POSTS0 COMMENTS
Shaida Kate Naidoo
6719 POSTS0 COMMENTS
Ted Musemwa
7002 POSTS0 COMMENTS
Thapelo Manthata
6678 POSTS0 COMMENTS
Umr Jansen
6690 POSTS0 COMMENTS