PHP | ImagickDraw setGravity() Function Last Updated : 30 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The ImagickDraw::setGravity() function is an inbuilt function in PHP which is used to set the text placement gravity when annotating with text. Syntax: bool ImagickDraw::setGravity( $gravity ) Parameters: This function accepts single parameter $gravity which is used to hold the value of gravity as GRAVITY_ constant. List of GRAVITY constants are given below: imagick::GRAVITY_NORTHWEST (integer) imagick::GRAVITY_NORTH (integer) imagick::GRAVITY_NORTHEAST (integer) imagick::GRAVITY_WEST (integer) imagick::GRAVITY_CENTER (integer) imagick::GRAVITY_EAST (integer) imagick::GRAVITY_SOUTHWEST (integer) imagick::GRAVITY_SOUTH (integer) imagick::GRAVITY_SOUTHEAST (integer) Return Value: This function does not return any value. Below programs illustrate the ImagickDraw::setGravity() function in PHP: Program 1: php <?php // Create an ImagickDraw object $draw = new ImagickDraw(); // Set the image filled color $draw->setFillColor('Green'); // Set the Font Size $draw->setFontSize(30); // Set the Gravity Position $draw->setGravity(5); // Set the font family $draw->setFontFamily('Ani'); // Set the text to be added $draw->annotation(30, 40, "GeeksForGeeks"); // Create new Imagick object $imagick = new Imagick();' // Set the image dimension $imagick->newImage(300, 150, 'white'); // Set the image format $imagick->setImageFormat("png"); // Draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $imagick->getImageBlob(); ?> Output: Program 2: php <?php // Create an ImagickDraw object $draw = new ImagickDraw(); // Set the image filled color $draw->setFillColor('green'); // Set the font size $draw->setFontSize(60); // Set the Gravity Position $draw->setGravity(2); // Set the text decoration $draw->setTextDecoration(4); // Set the text to be added $draw->annotation(50, 75, "GeeksForGeeks"); // Create new Imagick object $imagick = new Imagick(); // Set the image dimensions $imagick->newImage(600, 160, 'white'); // Set the image format $imagick->setImageFormat("png"); // Draw the image $imagick->drawImage($draw); header("Content-Type: image/png"); // Display the image echo $imagick->getImageBlob(); ?> Output: Reference: http://php.net/manual/en/imagickdraw.setgravity.php Comment More infoAdvertise with us S sarthak_ishu11 Follow Improve Article Tags : Technical Scripter Web Technologies PHP Image-Processing PHP-function PHP-Imagick +2 More Similar Reads JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Decorators in Python In Python, decorators are a powerful and flexible way to modify or extend the behavior of functions or methods, without changing their actual code. A decorator is essentially a function that takes another function as an argument and returns a new function with enhanced functionality. Decorators are 10 min read AVL Tree Data Structure An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. Balance Factor = left subtree height - right subtree heightFor a Balanced Tree(for every node): -1 ⤠Balance Factor ⤠1Example of an 4 min read Domain Name System (DNS) DNS is a hierarchical and distributed naming system that translates domain names into IP addresses. When you type a domain name like www.geeksforgeeks.org into your browser, DNS ensures that the request reaches the correct server by resolving the domain to its corresponding IP address.Without DNS, w 8 min read What is a Neural Network? Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamental 12 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read Like