PHP | Imagick setImageGravity() Function Last Updated : 22 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The Imagick::setImageGravity() function is an inbuilt function in PHP which is used to set the gravity property of an image. Difference between setGravity() and setImageGravity() is that the former applies for the whole Imagick object whereas the latter sets the gravity of the current image (in case of multiple images) in the sequence. Syntax: bool Imagick::setImageGravity( int $gravity ) Parameters: This function accepts single parameter $gravity which holds an integer value. List of GRAVITY constants are 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) Return Value: This function returns a boolean value. Below programs illustrate the Imagick::setImageGravity() function in PHP: Program 1: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Set the Gravity $imagick->setImageGravity(7); // Get the Gravity $gravity = $imagick->getImageGravity(); echo $gravity; ?> Output: 7 Program 2: php <?php // Create a new imagick object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Set the Gravity $imagick->setImageGravity(3); // Get the Gravity $gravity = $imagick->getImageGravity(); echo $gravity; ?> Output: 3 Reference: https://www.php.net/manual/en/imagick.setimagegravity.php Comment More infoAdvertise with us Next Article PHP | Imagick setImageGravity() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick setImageOpacity() Function The Imagick::setImageOpacity() function is an inbuilt function in PHP which is used to set the opacity level of an Imagick object. This method is available in ImageMagick 6.3.1 or newer versions. Syntax: bool Imagick::setImageOpacity( $opct ) Parameters: This function accepts single parameter $opct 1 min read PHP | Imagick setImageType() Function The Imagick::setImageType() function is an inbuilt function in PHP which is used to set the image type.Syntax:  bool Imagick::setImageType( int $image_type ) Parameters: This function accepts a single parameter $image_type which contains an integer value corresponding to one of IMGTYPE constants. W 1 min read PHP | Imagick setImageFormat() Function The Imagick::setImageFormat() function is an inbuilt function in PHP which is used to set the format of a particular image in a sequence.Syntax:  bool Imagick::setImageFormat( string $format ) Parameters: This function accepts a single parameter $format which holds a string value of the image forma 1 min read PHP | Imagick setImageUnits() Function The Imagick::setImageUnits() function is an inbuilt function in PHP which is used to set the units of resolution of a particular image.Syntax:  bool Imagick::setImageUnits( $units ) Parameters: This function accepts single parameter $units which is used to specify the units to be set for image. Res 2 min read PHP | Imagick setImageGamma() Function The Imagick::setImageGamma() function is an inbuilt function in PHP which is used to set the image gamma. Syntax: bool Imagick::setImageGamma( float $gamma ) Parameters: This function accepts a single parameter $gamma which holds the gamma for the image. Return Value: This function returns TRUE on s 1 min read Like