PHP | imageantialias() Function

The imageantialias() function is an inbuilt function in PHP which is used to check whether antialias function is used or not. This function activate the fast drawing anti-aliased methods for lines and wired polygons. It works only with truecolor images.


bool imageantialias( $image, $enabled )

Parameters: This function accepts two parameters as mentioned above and described below:

  • $image: An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
  • $enabled: This parameter is used to check whether enable antialiasing or not.

Return Value: This function returns True on success or False on failure.

Note: The imageantialias() function is now available. It was only available if PHP was compiled against version of the GD library.

Below program illustrates the imageantialias() function.

Program 1:





// Function to create image of given size
$antialias_img = imagecreatetruecolor(800, 200);
$normal_img = imagecreatetruecolor(400, 200);
// Switch antialiasing on for one image
imageantialias($antialias_img, true);
// Allocate the color for image
$white = imagecolorallocate($normal_img, 255, 255, 255);
$white_anti_aliased = imagecolorallocate($antialias_img, 255, 255, 255);
// Draw two lines, one with antialiasing enabled
imageline($normal_img, 0, 0, 400, 200, $white);
imageline($antialias_img, 0, 0, 400, 200, $white_anti_aliased);
// Merge the two images side by side for output
imagecopymerge($antialias_img, $normal_img, 400, 0, 0, 0, 400, 200, 200);
// Output image
header('Content-type: image/png');




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 or mail your article to 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.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.