Friday, October 10, 2025
HomeLanguagesPHP | imageantialias() Function

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.

Syntax:

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:




<?php
   
// 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');
   
imagepng($antialias_img);
imagedestroy($antialias_img);
imagedestroy($normal_img_img);
?>


Output:

Reference: http://php.net/manual/en/function.imageantialias.php

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7100 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS