Apply a filter to an image in PHP
Description
The following code shows how to apply a filter to an image.
Example
<?php/*from w ww . j av a2s .com*/
$im = imagecreatefrompng('test.png');
if($im && imagefilter($im, IMG_FILTER_GRAYSCALE))
{
echo 'Image converted to grayscale.';
imagepng($im, 'test.png');
}
else
{
echo 'Conversion to grayscale failed.';
}
imagedestroy($im);
?>
The code above generates the following result.