PHP | ImagickDraw getTextUnderColor() Function
The ImagickDraw::getTextUnderColor() function is an inbuilt function in PHP which is used to get the color of a background rectangle to place under text annotations. By default, this background rectangle is transparent.
Syntax:
ImagickPixel ImagickDraw::getTextUnderColor( void )
Parameters: This function doesn’t accepts any parameters.
Return Value: This function returns an ImagickPixel value containing the under color.
Below programs illustrate the ImagickDraw::getTextUnderColor() function in PHP:
Program 1:
<?php
$draw = new ImagickDraw();
$color = $draw ->getTextUnderColor()->getColorAsString();
echo $color ;
?>
|
Output:
srgba(0, 0, 0, 0) // Which is the default transparent color.
Program 2:
<?php
$draw = new ImagickDraw();
$draw ->setTextUnderColor( 'green' );
$color = $draw ->getTextUnderColor()->getColorAsString();
echo $color ;
?>
|
Output:
srgb(0, 128, 0)
Program 3:
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, '#1cced4' );
$draw = new ImagickDraw();
$draw ->setFontSize(35);
$draw ->setTextUnderColor( 'green' );
$draw ->annotation(50, 80, "The text under color here is "
. $draw ->getTextUnderColor()->getColorAsString());
$draw ->setTextUnderColor( 'blue' );
$draw ->annotation(50, 160, "The text under color here is "
. $draw ->getTextUnderColor()->getColorAsString());
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header( "Content-Type: image/png" );
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.gettextundercolor.php
Last Updated :
17 Dec, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...