Image manipulations with PHP5 and GD
Before the release of PHP5 if one wanted to manipulate images by applying filters, you’d have to either use an ImageMagick extension or create complicated matrices which you would then use the imageconvolution function.
With the introduction of PHP5 a new function is available called imagefilter. The parameters for the imagefilter function are bool imagefilter ( resource $image, int $filtertype [, int $arg1 [, int $arg2 [, int $arg3]]] ). Like most image functions in php, the first parameter is an image resource object created using one of the imagecreatefrom functions.
The second parameter is the name of one of the available filters. These are:
- IMG_FILTER_NEGATE -negates all the colors of the image.
- IMG_FILTER_GRAYSCALE -converts the image to grayscale.
- IMG_FILTER_BRIGHTNESS - changes the brightness of the image
- IMG_FILTER_CONTRAST- changes the contrast of the image
- IMG_FILTER_COLORIZE - colorscales the image to a given color
- IMG_FILTER_EDGEDETECT- highlights the edges of the image
- IMG_FILTER_EMBOSS -embosses an image
- IMG_FILTER_GAUSSIAN_BLUR - blurs the image in a Gaussian fashion
- IMG_FILTER_SELECTIVE_BLUR- blurs an image
- IMG_FILTER_MEAN_REMOVAL - makes an image look “sketchy”
The third and subsequent parameters only apply to certain filters. For the brightness and contrast filters, the third parameter must be a number between -255 and 255 where 0 is no change to the image and 255 is the maximum brightness/contrast. The only other filter with requires more parameters is the colorize filter. The third, fourth, and fifth parameter must be the RGB value of the desired color respectively.
Here are a few examples of the filter in use:

Blur:

Grayscale

Brightness:

As you can see complex effects are achieved more simply than in previous versions of php. If you wish to read more about the imgfilter function, check the PHP Manual

- Creating thumbnail - Resize an image with PHP
- Halftone Mania
- Digital Star Effect
- Energy Blast
- Extreme Logo
- Add a shiny metal object into your image - Realistic reflection
- Add a Dreamy or Misty Effect To Your Photos
- Learn to create your own Web2.0 Logo
- Rating and labelling your ASP.NET website
- Creating the Ajax application with Java
- Devil’s Eye
- Making of Fire Dragon
- Making Skin Beautiful
- Your Own Crazy Movie Poster
- Login Control in Visual Studio 2005
- Design a Classic Muscle Car Concept Depicting Horse Power
- Simple & cool urban-style logo
- Cartoonish enter leave buttons
- Create Ocean star fish water glass
- Make a realistic star field
Login
Friends' Sites
Contact Us
Categories
- 3D
- ASP
- C#
- CSS
- Database
- Flash
- GIMP
- Hosting
- Illustrator
- Java
- Javascript
- Linux
- Photoshop
- PHP
- Web Design
- Windows

2,611 views
No comments


No comments
Jump to comment form | comments rss [?] | trackback uri [?]