What is the function of imagefilter() in PHP?

The imagefilter() function in PHP is used to apply a filter to an image. This can be used to modify the appearance of an image by applying effects such as grayscale, brightness, contrast, blur, and more. By using imagefilter(), you can easily enhance or manipulate images in your PHP applications.

// Load the image
$image = imagecreatefromjpeg('example.jpg');

// Apply a grayscale filter
imagefilter($image, IMG_FILTER_GRAYSCALE);

// Output the modified image
header('Content-Type: image/jpeg');
imagejpeg($image);

// Free up memory
imagedestroy($image);