+

PHP ImaGick getGravity () function

Syntax:
int Imagick::getGravity (void)
Parameters:This function takes no parameters.Exceptions:This function throws an ImagickException on error.Return value:this function returns an integer value that represents the gravitational constant. 
The list of GRAVITY constants is given below:
  • imagick::GRAVITY_NORTHWEST (0)
  • imagick::GRAVITY_NORTH (1)
  • imagick: : GRAVITY_NORTHEAST (2)
  • imagick::GRAVITY_WEST (3)
  • imagick::GRAVITY_CENTER (4)
  • imagick::GRAVITY_EAST (5)
  • imagick::GRAVITY_SOUTHWEST (6)
  • imagick::GRAVITY_SOUTH (7)
  • imagick::GRAVITY_SOUTHEAST (8)
The programs below illustrate the Imagick::getGravity() functionin PHP:Program 1:  
// Create a new object imagick $imagick = new Imagick();  
// Get gravity $gravity = $imagick -> getGravity(); echo $gravity ; ?>
Output:
0 which corresponds to imagick::GRAVITY_NORTHWEST.
Program 2:  
// Create a new object imagick $imagick = new Imagick ( ` https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-13.png ` );  
// Set gravity $imagick -> setGravity (3);  
// Get gravity $gravity = $imagick -> getGravity(); echo $gravity ; ?>
Output:
3 which corresponds to imagick::GRAVITY_WEST.
Link: https://www.php.net/manual/en/imagick.getgravity.php
Get Solution for free from DataCamp guru