Open In App

PHP | ImagickDraw setTextAntialias() Function

Last Updated : 30 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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:




<?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();
?>


Output:
setTextAntialias

Program 2:




<?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();
?>


Output:
setTextAntialias

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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads