PHP | ImagickDraw setTextAlignment() Function
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.
Syntax:
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:
Program:
<?php // Create an ImagickDraw object $draw = new ImagickDraw(); // Set the image filled color $draw->setFillColor('white'); // Set the Font size $draw->setFontSize(40); // Set the text Alignment $draw->setTextAlignment(0); // Set the text to be added $draw->annotation(110, 75, "GeeksforGeeks!"); // Set the text alignment $draw->setTextAlignment(1); // Set the Font size $draw->setFontSize(20); // 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 $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.settextalignment.php
Recommended Posts:
- PHP | ImagickDraw arc() Function
- PHP | ImagickDraw setFontStyle() Function
- PHP | ImagickDraw setGravity() Function
- PHP | ImagickDraw polygon() Function
- PHP | ImagickDraw roundRectangle() Function
- PHP | ImagickDraw setStrokeWidth() Function
- PHP | ImagickDraw setStrokeOpacity() Function
- PHP | ImagickDraw setFontWeight() Function
- PHP | ImagickDraw setStrokeMiterLimit() Function
- PHP | ImagickDraw setFillOpacity() Function
- PHP | ImagickDraw point() Function
- PHP | ImagickDraw line() Function
- PHP | ImagickDraw setFillColor() Function
- PHP | ImagickDraw setFont() Function
- PHP | ImagickDraw setFontFamily() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



