Helping ordinary people create extraordinary websites!
 

8 Cool Functions in the GD2 extension

by Akash Mehta


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.

VN:F [1.8.2_1042]
Rating: 8.5/10 (2 votes cast)
8 Cool Functions in the GD2 extension8.5102


Tags: , ,


Showcase Your Tutorials

Related Posts
» Say hello to namespace naming conventions!
» Creating facebook like popup dialog in your web app
» Migrating legacy PHP 4 applications to PHP 5
» WebGrind: web-based frontend for XDebug PHP profiling
» jGrowl, an OS X Growl-like jQuery message plugin
 


Leave a Reply



GET OUR NEWSLETTERS