imageantialias 


gd apg

DECIDE if antialias functions will be used or not.





This function only works with TRUECOLOR images and does not support ALPHA components.

This function works using a direct blend operation.

This function doe not support thickness and styled.

Using antialiased primitives with transparent background color can end with some unexpected results.

The blend method uses the background color as any other colors.

The lack of ALPHA component support does not allow an ALPHA based antialiasing method

Since PHP 7.2.0 this function is generally available, which was only available if PHP was compiled with the bundled version of the GD library.

This function returns TRUE on success or FALSE on failure.



<?php

bool imageantialias 
( GdImage $image, bool $enable )


where,

$image = The image identifier

$enable 
= To stablish if antialias will be used or not

?>
 

  $image   


The image identifier.



  $enable   


Whether to enable antialiasing or not.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

$lang = 'en';

$sup_img = 'png/baseXx.png';

$res1_img = 'png/PNG 054 01 baseXx-alias.png';

$res2_img = 'png/PNG 054 01 baseXx-antialias.png';

$id_sup_img = imagecreatefrompng($sup_img);

$en = 'Existing Image' ;
 echo 
$sup_img . '<br><br>' . $$lang; ?>
<br><br><img src="<?php echo 
$sup_img; ?>" alt="<?php echo $sup_img; ?>"><br><br>

<?php

$x10 
= 30;
$y10 = 30;
$x1N = 340;
$y1N = 250;

$ln1_red = 0;
$ln1_green = 0;
$ln1_blue = 255;
$ln1_color = imagecolorallocate($id_sup_img, 
                                                   
$ln1_red, 
                                                   
$ln1_green, 
                                                   
$ln1_blue);

$x20 = 340;
$y20 = 50;
$x2N = 100;
$y2N = 250;

$ln2_red = 255;
$ln2_green = 0;
$ln2_blue = 0;
$ln2_color = imagecolorallocate($id_sup_img, 
                                                    
$ln2_red, 
                                                    
$ln2_green, 
                                                    
$ln2_blue);

$ln1 = imageline($id_sup_img, 
                           
$x10, $y10, 
                           
$x1N, $y1N, $ln1_color);
                                
$ln2 = imageline($id_sup_img, 
                           
$x20, $y20, 
                           
$x2N, $y2N, $ln2_color);

imagepng($id_sup_img, $res1_img);

imageantialias($id_sup_img, TRUE);

$ln1 = imageline($id_sup_img, 
                           
$x10, $y10, 
                           
$x1N, $y1N, $ln1_color);
                              
$ln2 = imageline($id_sup_img, 
                           
$x20, $y20, 
                           
$x2N, $y2N, $ln2_color);

imagepng($id_sup_img, $res2_img);

?>
<br>
<?php echo $res1_img; ?><br><br>
<img src="<?php echo $res1_img; ?>" 
alt="<?php echo $res1_img; ?>"><br><br><br>
<?php

echo $res2_img; ?>
<br><br><img src="<?php echo 
$res2_img; ?>" alt="<?php echo $res2_img; ?>"><br>


 RESULT   

baseXx.png

Existing Image

baseXx.png apr


PNG 054 01 baseXx-alias.png

PNG 054 01 baseXx-alias.png apr


PNG 054 01 baseXx-antialias.png

PNG 054 01 baseXx-antialias.png apr