PHP
  Home arrow PHP arrow Building an Image Generator Class with PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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: starstarstarstarstar / 10
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT