///8 Cool Functions in the GD2 extension

8 Cool Functions in the GD2 extension

Most PHP developers have at least heard of GD2; thanks to its prolific use in CAPTCHA generation, the image functions in PHP are standard practice for many. But the extension’s uses don’t end there. After the fold, here are eight cool things you probably weren’t aware could be done with GD2, and might be useful for your web applications.

(Note that a few of these may not be available depending on your PHP/GD setup, check the manual)

  1. Get the size of an icon file, with getimagesize() (also works on all standard image formats)
  2. Apply a gaussian-blur to an image, with imagefilter()
  3. Rotate an image, with imagerotate()
  4. Flood-fill an area of an image, with imagefill()
  5. Grayscale an image, also with imagefilter()
  6. Draw polygons and arcs — maybe for mathematical diagram? — with imagepolygon() and imagearc()
  7. Copy and resize a section of an image, with imagecopyresized()
  8. “Sketchify” images for a pencil-illustration-style effect, also with imagefilter() (see a pattern here?)

The phpied blog has some cool demos of the imagefilter() function download one night stand in particular.

2010-05-19T22:03:07+00:00 June 27th, 2008|PHP|0 Comments

About the Author:

Leave A Comment