Filters and effects from PHP GD

There are a set of filters that are built in to PHP GD library. You can get an overview of these filters and their arguments by reviewing the documentation for imagefilter().

A house, kodimg24.png, from The Kodak Colorset.

A house, kodimg24.png, from The Kodak Colorset.

Lets see some examples on using these filters. The base for all examples are:


#Filter Negate

This filter reverses all colors of the image.


#Filter Grayscale

This filter converts the image into grayscale.


#Filter Brightness

This filter changes the brightness of the image. Use arg1 to set the level of brightness. 0 is current setting, 255 is max light which means white and -255 is max dark meaning black.


#Filter Contrast

This filter changes the contrast of the image. Use arg1 to set the level of contrast. 0 is current setting, 100 is lowest contrast which means a completely gray image and -100 is max contrast.


#Filter Colorize

This is like the grayscale filter, except you can specify the color. Use arg1, arg2 and arg3 in the form of red, green, blue and arg4 for the alpha channel. The range for each color is 0 to 255 where a positive value enhances the color and a negative value decreases the color. For the alpha channel it is a value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

Enhance the green color &f=colorize,0,30,0,0  
Make it look golden with some brown tone &f=colorize,100,60,0,0  
Reduce the color red &f=colorize,-60,0,0,0  

#Filter Edge Detect

This filter uses edge detection to highlight the edges in the image.


#Filter Emboss

This filter embosses the image and gives it a 3D look.


#Filter Gaussian Blur

This filter blurs the image using the Gaussian method.


#Filter Selective Blur

This filter blurs the image.


#Filter Mean Removal

This filter uses mean removal to achieve a “sketchy” effect.


#Filter Smooth

This filter makes the image smoother. Use arg1 to set the level of smoothness. 0 gives a very smooth image

Smooth &f=smooth,0  
Some smothness &f=smooth,10  

This filter applies a 9-cell convolution matrix where center pixel has the weight arg1 and others weight of 1.0. Using negative values can produce some effects.

Make it unfocused &f=smooth,-5  
Show me the edges &f=smooth,-7  
Make it look sharper &f=smooth,-10  

#Filter Pixelate

This filter applies pixelation effect to the image, use arg1 to set the block size in pixels and arg2 to set the pixelation effect mode, whether to use advanced pixelation effect or not (defaults to FALSE).


#Combine filters

You can combine up to eleven filters by naming them f, f0-f9.

Make it grayscale and lighter.
Make it grayscale, lighter and enhance contrast.
Make it grayscale, lighter, enhance contrast & sharpen it.
Make it sepia, a bit old.

You can greatly enhance the perceived quality of the image by selecting a good combination of filters.