PHP
  Home arrow PHP arrow Page 2 - An Image is Worth a Thousand Words in ...
Dev Shed Forums 
Administration  
AJAX  
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 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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

An Image is Worth a Thousand Words in PHP
By: Brian Vaughn
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2005-12-14

    Table of Contents:
  • An Image is Worth a Thousand Words in PHP
  • Project Overview
  • Setting Up Our Class
  • The Browser Problem

  • 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


    An Image is Worth a Thousand Words in PHP - Project Overview


    (Page 2 of 4 )

    Admittedly, the program we are about to develop may lack an immediate, real-world application. So rather than contrive a situation in which we, as developers, would be asked to create such an application, let’s simply talk about what we will be designing our program to do. The benefits of such an exercise will then become clear as we work through the various stages of development.

    The basic goal of our application is simple: receive as a parameter a string designating the location of an image file (this can be a local image or a remote one), load the image, and convert it to a string of colored text that resembles the original picture. To go a step beyond that, we will also allow for multiple output modes including: color, grayscale, monochrome, and matrix. This will allow users to convert images to a variety of text-only formats. Below you’ll see a couple of ‘teaser’ sample images, displaying conversions in each of our various output formats:

     

    We’re going to be using an object-oriented programming approach, so we will start off by creating a class to contain our image manipulation methods. Let’s call this class ‘img_to_txt’, and let’s store it in a file named ‘img_to_txt.php’. For now its contents should be as follows:

    <?php
    # used to convert images to text-only format
    class img_to_txt {

    } # END img_to_txt class
    ?>

    Although there may not be an immediate need to re-use the methods we are about to create, it is still a good programming practice to make them as portable as possible. (After all, you never know when you may want to re-use something!) Because of this, we've chosen to bundle all of our code inside a simple helper class – but this class needs a few get-and-set methods in order to function properly. That’s what we’ll spend the first part of this article focusing on. Each of these methods will be pretty self-explanatory, and will simply allow us to define certain attributes of our image (such as its location, and the desired output format).

    More PHP Articles
    More By Brian Vaughn


       · hello!thanks to all of you who read this article. i hope you enjoyed it!please...
       · write faster, i want the second part of the class :)
       · I'm glad you're enjoying Brian's writing. The second (and last) part of the class is...
       · thank you! sounds like you don't have too long to wait :)
     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT