PHP Shape drawing tools

In a number of tutorials towards the end of last year we took a look at working with images in PHP.  The functionality and techniques that we looked at all worked with existing images that you had already taken with a digital camera, scanned in, or created yourself.  We saw how to make thumbnails, save these thumbnails in different formats and how to play with the colours within these images.  And this is all great if you have existing images to work with, but what happens if you want to draw simple shapes dynamically within your image?  The image functions within PHP can also do this and there are a number of functions, some of which you have already seen, that allow us to do this.
 
When most people think of creating images for web sites, they think of a program like Adobe Photoshop or Macromedia Fireworks and think of all the creative things they can do to make the page look good.  With enough time and effort you could get similar results using the PHP image functions, but this is not why we use them – these functions are aimed at more practical uses for images – creating simple navigation buttons on the fly, drawing maps or diagrams from raw data, annotating existing images or drawing graphs from dynamic data.
 
In today’s tutorial we will take a look at some of the basics for drawing shapes on an image; this tutorial can be used by itself, or as part of a series over the coming weeks which will demonstrate how to build  diagrams and charts on-the-fly from dynamic data.
$2.79
- OR -

Overview

Table of Content:

  • How to enable the GD extension
  • Creating an image
  • 3 colours purple
  • Drawing points, lines and boxes
  • Drawing a single point
  • Drawing a line
  • Drawing a rectangle
  • Conclusion

Allan Kent

Allan KentAllan comes from Cape Town, South Africa. He has been implicated in writing for several WROX, glasshaus, Wiley and Apress publications, generally in the 'cool stuff that PHP can do' sections.

You can catch up with him at his website http://www.mediafrenzy.co.za.

See All Postings From Allan Kent >>

Reviews

Be the first to write a review

You must me logged in to write a review.