Open In App

PHP | ImagickDraw setTextUnderColor() Function

Last Updated : 30 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The ImagickDraw::setTextUnderColor() function is an inbuilt function in PHP which is used to set the color of a background rectangle to place under text annotations. Syntax:
bool ImagickDraw::setTextUnderColor( $under_color )
Parameters: This function accepts a single parameter $under_color which is used to hold the value of background color of the text. Return Value: This function does not return any value. Below programs illustrate the ImagickDraw::setTextUnderColor() function in PHP: Program 1: php
<?php 

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

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

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

// Set the Text Under Color
$draw->setTextUnderColor('green');

// Set the text to be added
$draw->annotation(0, 190, "GeeksForGeeks");

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

// Set the text to be added
$draw->annotation(120, 290, "@sarthak_ishu11");

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

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

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

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

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

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

// Set the text to be added
$draw->annotation(0, 90, "GeeksForGeeks");

// Set the Text Under Color
$draw->setTextUnderColor('blue');

// Set the text to be added
$draw->annotation(0, 190, "GeeksForGeeks");

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

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

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

Next Article

Similar Reads