PHP | Imagick setImageOrientation() Function
Last Updated :
28 Nov, 2019
The Imagick::setImageOrientation() function is an inbuilt function in PHP which is used to set the image orientation. This function doesn’t actually rotate the image, it just changes the EXIF rotation info.
Syntax:
bool Imagick::setImageOrientation( int $orientation )
Parameters: This function accepts a single parameter $orientation which holds an integer value containing one of ORIENTATION constants. We can also pass a constant directly like setImageOrientation(imagick::ORIENTATION_BOTTOMRIGHT);.
List of ORIENTATION constants are given below:
- imagick::ORIENTATION_UNDEFINED (0)
- imagick::ORIENTATION_TOPLEFT (1)
- imagick::ORIENTATION_TOPRIGHT (2)
- imagick::ORIENTATION_BOTTOMRIGHT (3)
- imagick::ORIENTATION_BOTTOMLEFT (4)
- imagick::ORIENTATION_LEFTTOP (5)
- imagick::ORIENTATION_RIGHTTOP (6)
- imagick::ORIENTATION_RIGHTBOTTOM (7)
- imagick::ORIENTATION_LEFTBOTTOM (8)
Return Value: This function returns TRUE on success.
Below programs illustrate the Imagick::setImageOrientation() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$imagick ->setImageOrientation(imagick::ORIENTATION_LEFTTOP);
$orientation = $imagick ->getImageOrientation();
echo $orientation ;
?>
|
Output:
5 // Which corresponds to imagick::ORIENTATION_LEFTTOP.
Program 2:
<?php
$imagick = new Imagick(
$imagick ->setImageOrientation(imagick::ORIENTATION_RIGHTBOTTOM);
$orientation = $imagick ->getImageOrientation();
echo $orientation ;
?>
|
Output:
7 // Which corresponds to imagick::ORIENTATION_RIGHTBOTTOM.
Reference: https://www.php.net/manual/en/imagick.setimageorientation.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...