PHP | ImagickDraw getGravity() Function Last Updated : 07 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickDraw::getGravity() function is an inbuilt function in PHP which is used to get the text placement gravity used when annotating with text. Syntax: int ImagickDraw::getGravity( void ) Parameters: This function doesn’t accepts any parameters. Return Value: This function returns an integer value corresponding to one of GRAVITY constants or 0 when it is not set. List of GRAVITY constants are given below: imagick::GRAVITY_NORTHWEST (1) imagick::GRAVITY_NORTH (2) imagick::GRAVITY_NORTHEAST (3) imagick::GRAVITY_WEST (4) imagick::GRAVITY_CENTER (5) imagick::GRAVITY_EAST (6) imagick::GRAVITY_SOUTHWEST (7) imagick::GRAVITY_SOUTH (8) imagick::GRAVITY_SOUTHEAST (9) Below programs illustrate the ImagickDraw::getGravity() function in PHP: Program 1: php <?php // Create a new ImagickDraw object $draw = new ImagickDraw(); // Get the font Gravity $Gravity = $draw->getGravity(); echo $Gravity; ?> Output: 0 // Which is the default value. Program 2: php <?php // Create a new ImagickDraw object $draw = new ImagickDraw(); // Set the font Gravity $draw->setGravity(8); // Get the font Gravity $Gravity = $draw->getGravity(); echo $Gravity; ?> Output: 8 Program 3: php <?php // Create a new imagick object $imagick = new Imagick(); // Create a image on imagick object $imagick->newImage(800, 250, 'black'); // Create a new ImagickDraw object $draw = new ImagickDraw(); // Set the fill color $draw->setFillColor('cyan'); // Set the font size $draw->setFontSize(20); // Annotate a text to (50, 100) $draw->annotation(50, 100, 'The gravity here is ' . $draw->getGravity()); // Set the gravity $draw->setGravity(3); // Annotate a text to (50, 100) $draw->annotation(50, 100, 'The gravity here is ' . $draw->getGravity()); // Render the draw commands $imagick->drawImage($draw); // Show the output $imagick->setImageFormat('png'); header("Content-Type: image/png"); echo $imagick->getImageBlob(); ?> Output: Comment More infoAdvertise with us Next Article PHP | Imagick getImageGravity() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick getGravity() Function The Imagick::getGravity() function is an inbuilt function in PHP which is used to get the global gravity property for the Imagick object. Syntax: int Imagick::getGravity( void ) Parameters: This function does not accept any parameters. Exceptions: This function throws ImagickException on error. Retu 1 min read PHP | Imagick getImageGravity() Function The Imagick::getImageGravity() function is an inbuilt function in PHP which is used to get the image gravity. Difference between getGravity() and getImageGravity() is that the former applies for the whole Imagick object whereas the latter gets the gravity of the current image (in case of multiple im 1 min read PHP | ImagickDraw getStrokeOpacity() Function The ImagickDraw::getStrokeOpacity() function is an inbuilt function in PHP which is used to return the opacity of stroked object outlines. Syntax: float ImagickDraw::getStrokeOpacity( void ) Parameters: This function does not accepts any parameters. Return Value: This function returns stroke opacity 1 min read PHP | ImagickDraw getFillOpacity() Function The ImagickDraw::getFillOpacity() function is an inbuilt function in PHP which is used to get the opacity used when drawing using the fill color or fill texture. Fully opaque is 1 and fully transparent is 0. Syntax: float ImagickDraw::getFillOpacity( void ) Parameters: This function doesnât accept a 2 min read PHP | ImagickDraw getStrokeWidth() Function The ImagickDraw::getStrokeWidth() function is an inbuilt function of PHP which is used to return the width of the stroke used to draw object outlines. Syntax: float ImagickDraw::getStrokeWidth( void ) Parameters: This function does not accept any parameters. Return Value: This function returns strok 1 min read PHP | GmagickDraw getfillopacity() Function The GmagickDraw::getfillopacity() function is an inbuilt function in PHP which is used to get the opacity used when drawing using the fill color or fill texture. Fully opaque is 1 and fully transparent is 0. Syntax: float GmagickDraw::getfillopacity( void ) Parameters: This function doesnât accept a 2 min read Like