PHP includes simple image filtering capabilities provided by the GD extension.
The following filters are available, listed as the PHP constants:
- IMG_FILTER_NEGATE
- IMG_FILTER_GRAYSCALE
- IMG_FILTER_BRIGHTNESS
- IMG_FILTER_CONTRAST
- IMG_FILTER_COLORIZE
- IMG_FILTER_EDGEDETECT
- IMG_FILTER_EMBOSS
- IMG_FILTER_GAUSSIAN_BLUR
- IMG_FILTER_SELECTIVE_BLUR
- IMG_FILTER_MEAN_REMOVAL
- IMG_FILTER_SMOOTH
Some of them can be adjusted with additional parameters, such as contrast and smooth.
imagefilter($image_resource, FILTER)
Image resource can be created simply from an existing image by using function such as:
$image_resource = imagecreatefromjpeg("laughing-monkey.jpg");
Next step usually is to output the filtered image. This can be done in two ways by using the same function, print to browser or save to a local file. If you do not define the second parameter, the image will be shown to the browser.
imagejpeg($image_resource, "laughing-monkey-filtered.jpg");
A working example of all the filters is available here, applied to my story image thumbnails.