Open In App

PHP | ImagickDraw setTextDecoration() Function

Last Updated : 30 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The ImagickDraw::setTextDecoration() function is an inbuilt function in PHP which is used to specify the decoration to be applied when annotating with text. Syntax:
bool ImagickDraw::setTextDecoration( $decoration )
Parameters: This function accepts a single parameter $decoration which is used to hold the value of DECORATION_ constant. The list of DECORATION_ constants are given below:
  • imagick::DECORATION_NO (integer)
  • imagick::DECORATION_UNDERLINE (integer)
  • imagick::DECORATION_OVERLINE (integer)
  • imagick::DECORATION_LINETROUGH (integer)
Return Value: This function does not return any value. Below programs illustrate the ImagickDraw::setTextDecoration() function in PHP: Program 1: php
<?php

// Create an ImagickDraw object
$draw = new ImagickDraw();

// Set the image filled color 
$draw->setFillColor('green');

// Set the font size
$draw->setFontSize(60);

// Set the Text Decoration
$draw->setTextDecoration(4);

// Set the text to be added
$draw->annotation(50, 75, "GeeksForGeeks");
 
// Create new Imagick Object
$imagick = new Imagick();

// Set image dimensions
$imagick->newImage(500, 160, 'white');

// 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: setTextDecoration Program 2: php
<?php

// Create an ImagickDraw object
$draw = new ImagickDraw();

// Set the image filled color 
$draw->setFillColor('yellow');

// Set the font size
$draw->setFontSize(20);

// Set the TextDecoration() function
// Text is Upperline
$draw->setTextDecoration(3);
// Set the text to be added
$draw->annotation(50, 75, "A Computer Science Portal For Geeks!");

// Create new Imagick Object 
$imagick = new Imagick();

// Set the image dimensions
$imagick->newImage(500, 160, 'black');

// 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: setTextDecoration Reference: http://php.net/manual/en/imagickdraw.settextdecoration.php

Next Article

Similar Reads