PHP ImagickDraw function setTextAlignment ()

PHP

Syntax:
bool ImagickDraw::setTextAlignment ($alignment)
Parameters: This function takes one $alignment parameter, which is used to store the value of the ALIGN_ constants.The ALIGN_ constants are listed below:
  • Imagick::ALIGN_UNDEFINED (integer)
  • Imagick::ALIGN_LEFT (integer)
  • Imagick::ALIGN_CENTER (integer)
  • Imagick::ALIGN_RIGHT (integer)
Returned value:this function does not return any value.The program below illustrates the ImagickDraw::setTextAlignment() function in PHP:Program :  
// Create an ImagickDraw object $draw = new ImagickDraw();  
// Set the fill color of the image $draw -> setFillColor ( `white` );  
// Set font size $draw -> setFontSize (40);  
// Set text alignment $draw -> setTextAlignment (0);  
// Set text to add $draw -> annotation (110, 75, "GeeksforGeeks!" );  
// Set text alignment $draw -> setTextAlignment (1);  
// Set font size $draw -> setFontSize (20);  
// Set text to add $draw -> annotation (100, 110, "A computer science portal for engineer " );  
// Create a new imagick object $imagick = new Imagick();  
// Set image size $imagick -> newImage (500, 300, `green` );  
// Set image format $imagick -> setImageFormat ( "png" );  
// Draw image $imagick -> drawImage ( $draw ); header ( "Content-Type: image / png" );  
// Show image echo $imagick -> getImageBlob(); ?>
Output: Link: http://php.net/manual/en/imagickdraw.settextalignment.php



Get Solution for free from DataCamp guru