PHP Classes
Icontem

File: exe.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Sebastian Röbke  >  Boosty's ASCII Artist  >  exe.php  
File: exe.php
Role: Example script
Content type: text/plain
Description: Example script called by index.html
Class: Boosty's ASCII Artist
Converts images into some kind of ASCII Art
 

Contents

Class file image Download
<?php
// Boosty's ASCIIArtist (http://www.sebastian-r.de/asciiart/)
// exe.php
// This script is called by the settings form (index.html)
// and starts the ASCIIArtist accordingly

// Load ASCIIArtist class file
require ('ASCIIArtist.php');
?>
<html>
<head>
    <title>Boosty's ASCIIArtist</title>
</head>
<body>
<div align="center">
<?php
// Image location submitted?
if (empty($_REQUEST['image'])) {
    echo 
'<p style="font-family: Verdana, sans-serif; font-size: 11px;">Error: No image location specified.</p>';
} else {
    
// OK, let's get it on!
    
    // Create an ASCIIArtist object
    
$ASCIIArtist = &new ASCIIArtist;
    
    
// Set the given image file location (will return false if an error occurs)
    
if (!$ASCIIArtist->setFile($_REQUEST['image'])) {
        
// An error occured!
        
echo $ASCIIArtist->getHTMLErrors();
    } else {
        
// Flip horizontally?
        
if ($_REQUEST['flip_h']) {
           
$flip_h true;
        } else {
            
$flip_h false;
        }
        
        
// Flip vertically?
        
if ($_REQUEST['flip_v']) {
            
$flip_v true;
        } else {
            
$flip_v false;
        }
        
        
// Set the CSS as desired
        
$ASCIIArtist->setImageCSS('
            color           : '
.$_REQUEST['color'].';
            background-color: transparent;
            font-size       : '
.$_REQUEST['font-size'].'px;
            font-family     : "Courier New", Courier, mono;
            line-height     : '
.$_REQUEST['line-height']."px;
            letter-spacing  : "
.$_REQUEST['letter-spacing'].'px;
        '
);
        
        
// Convert the image        
        
$ASCIIArtist->renderHTMLImage($_REQUEST['mode'], $_REQUEST['resolution'], $_REQUEST['fixed_char'], $flip_h$flip_v);
    
        
// Print converted image as HTML
        
echo $ASCIIArtist->getHTMLImage();
        
        
// Show the original image aswell
        
echo '<br><p style="font-family: Verdana, sans-serif; font-size: 11px;">Original Image:<br><img src="'.$_REQUEST['image'].'" height="'.$ASCIIArtist->getImageHeight().'" width="'.$ASCIIArtist->getImageWidth().'" alt="'.$_REQUEST['image'].', '.$ASCIIArtist->getImageWidth().' x '.$ASCIIArtist->getImageHeight().' px"></p>';
    }
}
?>
<p style="font-family: Verdana, sans-serif; font-size: 11px;">Powered by <a href="http://www.sebastian-r.de/asciiart/">Boosty's ASCIIArtist</a></p>
</div>
</body>
</html>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products