Open In App

PHP | imageantialias() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 01 Nov, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads