Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PHP | ImagickDraw setTextAlignment() Function

  • Difficulty Level : Medium
  • Last Updated : 30 Aug, 2019

The ImagickDraw::setTextAlignment() function is an inbuilt function in PHP which is used to specify a text alignment which can be left, center or right.


bool ImagickDraw::setTextAlignment( $alignment )

Parameters: This function accepts a single parameter $alignment which is used to hold the value of ALIGN_ constants.

List of ALIGN_ constants are given below:

  • Imagick::ALIGN_UNDEFINED (integer)
  • Imagick::ALIGN_LEFT (integer)
  • Imagick::ALIGN_CENTER (integer)
  • Imagick::ALIGN_RIGHT (integer)

Return Value: This function does not return any value.

Below program illustrates the ImagickDraw::setTextAlignment() function in PHP:


// Create an ImagickDraw object
$draw = new ImagickDraw();
// Set the image filled color 
// Set the Font size
// Set the text Alignment
// Set the text to be added
$draw->annotation(110, 75, "GeeksforGeeks!");
// Set the text alignment 
// Set the Font size
// Set the text to be added
$draw->annotation(100, 110, "A computer science portal for geeks");
// Create new imagick object
$imagick = new Imagick();
// Set the image dimension
$imagick->newImage(500, 300, 'green');
// Set the image format
// Draw the image
header("Content-Type: image/png");
// Display the image
echo $imagick->getImageBlob();



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!