Easy Tutorial
❮ Func Misc Sleep Func Date Timezone Set ❯

PHP imageantialias - Whether to Use Antialiasing Function

PHP Image Processing

imageantialias — Whether to use antialiasing function.

Syntax

bool imageantialias ( resource $image , bool $enabled )

Enables a fast drawing antialiasing method for lines and polygons. Does not support alpha parts. Uses direct blending operations. Only for true color images.

Does not support line width and style.

Using antialiasing and a transparent background color may produce unexpected results. The blending method treats the background color as any other color. The lack of alpha part support results in the disallowance of alpha-based antialiasing methods.

Parameters

Return Value

Returns TRUE on success, or FALSE on failure.

Example

<?php
// Using an antialiased image and a normal image
$aa = imagecreatetruecolor(400, 100);
$normal = imagecreatetruecolor(200, 100);

// Enable antialiasing
imageantialias($aa, true);

// Set colors
$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);
?>

The above example outputs an image as follows:

PHP Image Processing

❮ Func Misc Sleep Func Date Timezone Set ❯