PHP | ImagickDraw getTextAntialias() Function
Last Updated :
02 May, 2023
The ImagickDraw::getTextAntialias() function is an inbuilt function in PHP that is used to get the current text to antialias setting, which determines whether the text is antialiased. Text Antialias is enabled by default. Alias is just noise or distortion in the text.
Syntax:
bool ImagickDraw::getTextAntialias( void )
Parameters: This function doesn’t accept any parameter.
Return Value: This function returns a bool value that tells whether Antialias is enabled or disabled.
Exceptions: This function throws ImagickException on error. Below given programs illustrate the ImagickDraw::getTextAntialias() function in PHP:
Program 1:
php
<?php
$draw = new ImagickDraw();
$textAntialias = $draw ->getTextAntialias() ? 'true' : 'false' ;
echo $textAntialias ;
?>
|
Output:
true // which is the default value.
Program 2:
php
<?php
$draw = new ImagickDraw();
$draw ->setTextAntialias(false);
$textAntialias = $draw ->getTextAntialias() ? 'true' : 'false' ;
echo $textAntialias ;
?>
|
Output:
false
Program 3:
php
<?php
$imagick = new Imagick();
$imagick ->newImage(800, 250, 'black' );
$draw = new ImagickDraw();
$draw ->setFillColor( 'white' );
$draw ->setStrokeWidth(1);
$draw ->setStrokeColor( 'red' );
$draw ->setFontSize(30);
$TextAntialias = $draw ->getTextAntialias() ? 'true' : 'false' ;
$draw ->annotation(50, 100, 'Text antialias here is ' . $TextAntialias );
$draw ->setTextAntialias(false);
$TextAntialias = $draw ->getTextAntialias() ? 'true' : 'false' ;
$draw ->annotation(50, 200, 'Text antialias here is ' . $TextAntialias );
$imagick ->drawImage( $draw );
$imagick ->setImageFormat( 'png' );
header("Content-Type: image/png");
echo $imagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/imagickdraw.gettextantialias.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...