Home arrow PHP arrow Page 5 - An Image is Worth a Thousand Words in PHP Continued

In Conclusion - PHP

Picking up where we left off in part one, we will work on some more helper methods and our conversion method. By the time we are done, we will have a fully functional image to text converter.

TABLE OF CONTENTS:
  1. An Image is Worth a Thousand Words in PHP Continued
  2. Examining the Code
  3. Final Preparation
  4. Converting An Image
  5. In Conclusion
By: Brian Vaughn
Rating: starstarstarstarstar / 5
December 21, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

That's it. We now have a working conversion library - but we still haven't seen how it works! Let's try it out by converting a familiar graphic. Go ahead and create a file - (you can name it anything you like, so long as it has a .php extension) - and put in it the following code:

<html>
<head>
<title>IMG_TO_TXT</title>
<style type="text/css">
 strong, b {
  color: #FFFFFF;
  font-family: Tahoma, Arial, Verdana, Helvetica, sans-serif;
  font-size: 11px;
 }
</style>
</head>

<body bgcolor="#000000">

<?php
 include_once 'img_to_txt.php';
 $img_to_txt = new img_to_txt();
 $img_to_txt->set_chars( 'MYNAMEISBRIAN' );
?>

 <b>Color:</b><br>
<?php
 $img_to_txt->load_image( 'http://www.google.com/intl/en/images/logo.gif' );
 echo $img_to_txt->get_image();
?>

 <br><b>Grayscale:</b><br>
<?php
 $img_to_txt->set_return_format( 'grayscale' );
 echo $img_to_txt->get_image();
?>


 <br><b>Matrix:</b><br>
<?php
 $img_to_txt->set_return_format( 'matrix' );
 echo $img_to_txt->get_image();
?>


 <br><b>Monochrome:</b><br>
<?php
 $img_to_txt->set_return_format( 'monochrome' );
 echo $img_to_txt->get_image();
?>

</body>
</html>

The above demonstration converts the familiar Google image into several text-only modes. You may view this example online here:

http://images.devshed.com/ds/stories/Image_is_Words/IMG_TO_TXT.htm

If you have not followed along but would still like to download the source code, it may be found online here:

http://images.devshed.com/ds/stories/Image_is_Words/img_to_txt.zip

I hope this has been a useful exercise for any of you who have taken the time to complete it. Thank you for your time, and please let me know if you have any questions/comments. Until next time...



 
 
>>> More PHP Articles          >>> More By Brian Vaughn
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: