The Imagick::getImageOrientation() function is an inbuilt function in PHP which is used to get the image orientation.
Syntax:
int Imagick::getImageOrientation( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns an integer value containing one of ORIENTATION constants.
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)
Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::getImageOrientation() function in PHP:
Program 1:
<?php // Create a new imagick object $imagick = new Imagick( // Get the Orientation $orientation = $imagick ->getImageOrientation(); echo $orientation ; ?> |
Output:
0 // Which corresponds to imagick::ORIENTATION_UNDEFINED.
Program 2:
<?php // Create a new imagick object $imagick = new Imagick( // Set the Orientation $imagick ->setImageOrientation(imagick::ORIENTATION_TOPRIGHT); // Get the Orientation $orientation = $imagick ->getImageOrientation(); echo $orientation ; ?> |
Output:
2
Reference: https://www.php.net/manual/en/imagick.getimageorientation.php