English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP imageantialias() function usage and example of using antialiasing (antialias) feature

PHP Image Processing

imageantialias — whether to use antialiasing (antialias) feature.

syntax

bool imageantialias ( resource $image , bool $enabled )

Enable fast drawing antialiasing method for line segments and polygons. The alpha channel is not supported. Use direct blending operations. Only for truecolor images.

Line width and style are not supported.

Using antialiasing and transparent background color may result in unexpected results. The blending method treats the background color as any other color. Lack of alpha channel support leads to the inability to use alpha-based antialiasing methods.

parameter

  • image: image resource returned by image creation functions (e.g., imagecreatetruecolor()).

  • enabled: whether antialiasing is enabled.

return value

returns TRUE on success, or FALSE on failure.

example

<?php
//  use antialiasing image and a normal image
$aa = imagecreatetruecolor(400, 100);
$normal = imagecreatetruecolor(200, 100);
// use antialiasing feature
imageantialias($aa, true);
// set color
$red = imagecolorallocate($normal, 255, 0, 0);
$red_aa = imagecolorallocate($aa, 255, 0, 0);
// draw two lines
imageline($normal, 0, 0, 200, 100, $red);
imageline($aa, 0, 0, 200, 100, $red_aa);
// merge images
imagecopymerge($aa, $normal, 200, 0, 0, 0, 200, 100, 100);
// output image
header('Content-type: image/png');
imagepng($aa);
imagedestroy($aa);
imagedestroy($normal);
?>

PHP Image Processing