PHP | Gmagick annotateImage() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The Gmagick::annotateImage() function is an inbuilt function in PHP which is used to annotates an image with text. This function returns True on success. Syntax: Gmagick Gmagick::annotateimage( $GmagickDraw, $x, $y, $angle, $text ) Parameters: This function accepts five parameters as mentioned above and described below: $GmagickDraw: This parameter is used to create an GmagickDraw object that contains settings for drawing the text. $x: This parameter is set to horizontal offset in pixels to the left of text. $y: This parameter is set to vertical offset in pixels to the baseline of text. $angle: The angle at which to write the text. $text: The string which needs to draw. Return Value: This function returns Gmagick object with annotation made. Below programs illustrate the Gmagick::annotateImage() function in PHP: Program 1: php <?php /* Create some objects */ $image = new Gmagick(); $draw = new GmagickDraw(); $pixel = new GmagickPixel('white'); /* New image */ $image->newImage(800, 300, $pixel); /* Black text */ $draw->setFillColor('green'); /* Font properties */ $draw->setFont('Bookman-DemiItalic'); $draw->setFontSize( 30 ); /* Create text */ $image->annotateImage($draw, 30, 140, 0, 'GeeksforGeeks: A computer science portal'); /* Give image a format */ $image->setImageFormat('png'); /* Output the image with headers */ header('Content-type: image/png'); echo $image; ?> Output: Program 2: php <?php /* Create some objects */ $image = new Gmagick(); $draw = new GmagickDraw(); $image = new Gmagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); /* Black text */ $draw->setFillColor('green'); /* Font properties */ $draw->setFont('Bookman-DemiItalic'); $draw->setFontSize( 30 ); /* Create text */ $image->annotateImage($draw, 5, 120, 0, 'GeeksforGeeks: A computer science portal'); /* Give image a format */ $image->setImageFormat('png'); /* Output the image with headers */ header('Content-type: image/png'); echo $image; ?> Output: Reference: https://www.php.net/manual/en/gmagick.annotateimage.php Create Quiz Comment R R_Raj Follow 0 Improve R R_Raj Follow 0 Improve Article Tags : Web Technologies PHP Image-Processing PHP-Gmagick Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like