PHP Classes

File: exe.php

Recommend this page to a friend!
  Classes of Sebastian Röbke   Boosty's ASCII Artist   exe.php   Download  
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
Author: By
Last change: - Updated to be used with the latest ASCIIArtist class version
- Added comments
Date: 20 years ago
Size: 2,488 bytes
 

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>