How to check antialias functions be used or not by using imageantialias() function in PHP?

PHPServer Side ProgrammingProgramming

imageantialias() is an inbuilt function in PHP that is used to check whether antialias function is used or not. It activates the fast drawing anti-aliased methods for lines and wired polygons. It works only with true-color images and it doesn't support alpha components.

Syntax

bool imageantialias($image, $enabled)

Parameters

imageantialias() takes two parameters: $image and $enabled.

  • $image − The $image parameter is a GdImage object and an image resource that is returned by the image creation function imagecreatetruecolor.

  • $enabled − The $enabled parameter is used to check whether antialiasing is enabled or not

Return Values

imageantialias() returns True on success and False on failure.

Example 1

<?php
   // Setup an anti-aliased image and a normal image
   $img = imagecreatetruecolor(700, 300);
   $normal = imagecreatetruecolor(700, 300);

   // Switch antialiasing on for one image
   imageantialias($img, true);

   // Allocate colors
   $blue = imagecolorallocate($normal, 0, 0, 255);
   $blue_aa = imagecolorallocate($img, 0, 0, 255);

   // Draw two lines, one with AA enabled
   imageline($normal, 0, 0, 400, 200, $blue);
   imageline($img, 0, 0, 400, 200, $blue_aa);

   // Merge the two images side by side for output (AA: left, Normal: Right)
   imagecopymerge($img, $normal, 400, 0, 0, 0, 400, 200, 200);

   // Output image
   header('Content-type: image/png');
   imagepng($img);
   imagedestroy($img);
   imagedestroy($normal);
?>

Output

raja
Published on 09-Aug-2021 13:55:34
Advertisements