PHP
  Home arrow PHP arrow Building an Image Generator Class with...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building an Image Generator Class with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-10-01

    Table of Contents:
  • Building an Image Generator Class with PHP 5
  • Defining the basic structure of a image generator class in PHP 5
  • Implementing the buildImageStream() and displayImage() methods
  • Testing the ImageGenerator class

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Ziff Davis Enterprise Virtual Tradeshows: Hot Topics, Cutting Edge Technology, Real-time Interaction with IT Professionals. Learn more at ziffdavisvts.com

    Building an Image Generator Class with PHP 5
    (Page 1 of 4 )

    In this article, you will learn how to build an image generator class with PHP 5, using the functions bundled with the GD library. Such a class has a wide variety of uses, but for the purposes of this three-part series, we will focus on creating a function for displaying noisy images (also known as captchas) on the browser.

    Introduction

    Undeniably, PHP is widely recognized by many web programmers as a general server-side scripting language with a remarkable capacity for tackling the development of a huge variety of applications. These applications can range from basic form validation classes and efficient database abstraction layers to more complex projects, such as fully-featured discussion forums, powerful web-based MySQL front-ends and popular content management systems.

    The release of PHP 5 has provided seasoned PHP developers with a robust set of functions and object-based features that make this version of the scripting language one of the most used for building robust web applications with minor hassles. This versatility is particularly in evidence when it comes to generating and manipulating dynamic image streams via the popular GD extension. This library comes packaged with a neat arsenal of graphic processing functions for quickly and easily developing image-centric applications.

    However, it isn't my intention to provide you a with a detailed guide on how to put the GD extension to work for you, since I already wrote an extensive series of articles, which were published here, on the prestigious Developer Shed Network.

    Instead, I'd like to take a different course of action, slightly more pragmatic, and show you how to utilize some of the functions bundled with the GD library to build a highly expansible image generator class. Thanks to its fairly skeletal structure, this class will be easy to customize to suit the requirements of different PHP applications.

    In simple terms, over the course of this brand new PHP series, which will be comprised of three friendly tutorials, I'll walk you through the development of an easy-to-follow PHP class that will have the ability to build dynamic text strings, which will be outputted straight to the browser in the form of image streams.

    Of course, if you reread the previous sentence, then you'll realize the huge range of PHP applications that might take advantage of the basic functionality provided by the class that I plan to create here. In this case, however, I'll focus the whole development process on using the class in question to build an application aimed at displaying noisy images (also widely known as captchas).

    The structure of this image generating class will be extremely pluggable, which implies that you can use it for other purposes, but hopefully the whole learning experience will serve as an introduction to using some functions included with the GD extension in the context of the object-oriented paradigm.

    All right, providing that the development of an image generator class with PHP 5 may be an interesting topic to you, let's not waste more time in preliminaries and start building the core structure of this PHP 5-based class. It's going to be an instructive journey, trust me!

    More PHP Articles
    More By Alejandro Gervasio


       · As you’ll probably know, PHP 5 really shines when it comes to building...
     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway