PHP Imagick annotateImage () function

PHP

Syntax:
bool Imagick::annotateImage ($draw_settings, $x, $y, $angle, $text)  Parameters:This function takes five parameters as above and described below:
  • $draw_settings:this parameter is used for creating an ImagickDraw object that contains settings for drawing text.
  • $x:This parameter is set to a horizontal offset in pixels to the left of the text.
  • $y:this parameter is set to a vertical offset in pixels from the baseline of the text.
  • $angle:the angle at which the text is written
  • $text:the line to draw.
Return value:this function returns True on success.The following programs illustrate the Imagick::annotateImage()function in PHP:Program 1:
/ * Create multiple objects * / $image = new Imagick ( ); $draw = new ImagickDraw(); $pixel = new ImagickPixel ( `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` );  
/ * Set image as * / $image -> setImageFormat ( `png` );  
/ * Output image with titles * / header ( `Content-type: image / png` ); echo $image ;  
?>
Output: Program 2:  
/ * Create multiple objects * / $image = new Imagick(); $draw = new ImagickDraw(); $image = new Imagick ( ` https://media.engineerforengineer.org/wp-content/uploads/engineerforengineer-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` );  
/ * Set image in * / $image -> setImageFormat ( `png` );  
/ * Output image with titles * / header ( `Content-type: image / png` ); echo $image ;  
?>
Output: Related Articles:
  • PHP | Imagick addNoiseImage() function
  • PHP | Imagick addImage() function
Link: http://php.net/manual/en/imagick.annotateimage.php



Get Solution for free from DataCamp guru