PHP | ImagickDraw setTextAntialias() Function

The ImagickDraw::setTextAntialias() function is an inbuilt function in PHP which is used to control whether the text is antialiased. The text is antialiased by default.

Syntax:

bool ImagickDraw::setTextAntialias( $antiAlias )

Parameters: This function accepts a single parameter $antiAlias which is used to store the Boolean Signal i.e. TRUE/FALSE.

Return Value: This function does not return any value.

Below programs illustrate the ImagickDraw::setTextAntialias() function in PHP:



Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create an ImagickDraw object
$draw = new ImagickDraw();
   
// Set the image filled color
$draw->setFillColor('green');
  
// Set the font size
$draw->setFontSize(50);
  
// Set the Text Antialias
$draw->setTextAntialias(false);
  
// Set the text to be added
$draw->annotation(50, 75, "Gfg!");
  
// 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();
?>

chevron_right


Output:
setTextAntialias

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create an ImagickDraw object
$draw = new ImagickDraw();
  
// Set the image filled color 
$draw->setFillColor('orange');
  
// Set the font size
$draw->setFontSize(50);
  
// Set the TextAntialias function
$draw->setTextAntialias(true);
  
// Set the text to be added
$draw->annotation(5, 75, "Gfg!");
  
// Set the TextAntialias function
$draw->setTextAntialias(false);
  
// Set the text to be added
$draw->annotation(105, 75, "Gfg!");
  
// Create new Imagick object
$imagick = new Imagick();
  
// Set the image dimensions
$imagick->newImage(300, 160, '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();
?>

chevron_right


Output:
setTextAntialias

Reference: http://php.net/manual/en/imagickdraw.settextantialias.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.