PHP Classes
elePHPant
Icontem

Image2HTML: Convert images into colored HTML text

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2009-08-12 (7 years ago) RSS 2.0 feedNot enough user ratingsTotal: 588 This week: 2All time: 5,015 This week: 591Up
Version License PHP version Categories
image2html 1.0Free for non-comm...4.0HTML, Graphics
Description Author

This class can be used to convert images into colored HTML text.

It can open an image in JPEG format and traverse its pixels to generate HTML that renders the image as a sequence of colored characters of 1 pixel of width and height.

The generated HTML can be saved to a given file.

Picture of Reza Salehi
Name: Reza Salehi <contact>
Classes: 18 packages by
Country: Canada Canada
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

Details
Auther
------
Reza Salehi, reza@dreamstube.com

image2html
----------
This class takes a Jpeg or Gif image and converts it to HTML tags.
The generated HTML is accessible via a public field and also can be saved in a HTML file
or gets printed directly.

How to Use this class
---------------------
Please take a look at the attached client.php file.

First, an instance of this class should be created by passing the following parameters to 
the constructor:
	- uploadedFilePath: The path to the uploaded image.
	- result file path: The path to the generated HTML file.
	- The character to use in the HTML image as a pixel.
	- Maximum width of the input image.
	- Maximum height of the imput image.

Please take a look at the following code:

// Creates an instance of the converter class
$Image2TextInstance = new Image2Html($uploadedFilePath, $uploadedFilePath . ".html", "█", 400, 300);


After creating the instance, you have to call the GetHtmlFromImage() function 
to generate the HTML as follows:
// Does the actual conversion
$Image2TextInstance->GetHtmlFromImage();

At last you have to save the file on disk by calling WriteToFile():
// Write the converted file to an HTML file as well as printing it directly!
$Image2TextInstance->WriteToFile();

OR 

Print the HTML directly link the following:
<?php print($Image2TextInstance->_textData); ?>


IMPORTANT: Please make sure you create [conversions] folder on the same path you are running this script.
--END OF DOCUMENT--



Screenshots  
  • image2htmlScreen
  Files folder image Files  
File Role Description
Plain text file client.php Example Client Script
Plain text file image2html.class.php Class The Main Class File
HTML file index.html Data User form
Image file php.jpg Icon Test image file
Plain text file ReadMe Doc. Help File

 Version Control Unique User Downloads Download Rankings  
 0%
Total:588
This week:2
All time:5,015
This week:591Up
User Comments (1)