Tema: Error
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/10/2003, 17:05
Jorgelongolongo
 
Fecha de Ingreso: agosto-2003
Ubicación: Mexico Df abajo del puente de municipio
Mensajes: 216
Antigüedad: 23 años, 1 mes
Puntos: 0
De acuerdo Error

Que es lo k falla de aki¿?

Fatal error: Call to undefined function: imagecreatefrompng() in c:\apache\htdocs\index.php on line 142


Código PHP:

<?php
////////////////////////////////////////////////////////////////////////////////
// Boosty's ASCII Artist 1.0
////////////////////////////////////////////////////////////////////////////////
// Converts PNG images into nice ASCII Texts
////////////////////////////////////////////////////////////////////////////////
// Author:        Sebastian Röbke <[email protected]>
// Last modified: 2001-11-17
////////////////////////////////////////////////////////////////////////////////

// Imagefolder
$imagefolder = "./png/";

// Replace characters (from dark to light, 9 variations)
$replace_characters = array (
    
1 => "@",
    
2 => "#",
    
3 => "*",
    
4 => "+",
    
5 => ":",
    
6 => ".",
    
7 => "'",
    
8 => "&nbsp;",
    
9 => "&nbsp;"
);

// Available Images as PNG (as set by $imagefolder)
$handle=opendir($imagefolder);
while (
$file = readdir($handle)) {
    if (
$file != "." && $file != "..") {
        
$images[] = $file;
    }
}
closedir($handle);
sort($images);
reset($images);

// Default Image
if (!isset($image) || !in_array($image, $images)) $image = $images[0];

// Default Quality
if (!isset($quality) || $quality < 1 || $quality > 10) $quality = 2;

// Default Fixed Char for Colorize mode
if (!isset($fixed_char)) $fixed_char = "@";

// Default Mode
if (!isset($mode)) $mode = "standard";

// string function hexColor (array $rgb)
// Convert the $rgb array to a hex value
function hexColor($rgb) {
    return 
sprintf("%02X%02X%02X",$rgb["red"],$rgb["green"],$rgb["blue"]);
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <title>Boosty's ASCII Artist</title>
    <style>
    body, input, select, option, p, td
    {
        font-family: Verdana, sans-serif;
        font-size: 11px;
    }
    .image
    {
        font-family: "Courier New", Courier, monospace;
        font-size: 8px;
        line-height: 5px;
    }
    </style>
</head>

<body>
<div align="center">
<form action="index.php" method="POST">
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#4e4e4e">
    <tr>
        <td>
            <table border="0" cellspacing="0" cellpadding="4" bgcolor="#cccccc">
                <tr bgcolor="#33ccff">
                    <td colspan="3" align="center"><b>Boosty's ASCII Artist</b></td>
                </tr>
                <tr>
                    <td colspan="3"><b>Choose mode</b></td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        <input type="Radio" name="mode" value="standard"<?php if($mode=="standard") echo " checked"; ?>>Standard
                        <input type="Radio" name="mode" value="colorize"<?php if($mode=="colorize") echo " checked"; ?>>Colorize
                        <input type="Radio" name="mode" value="colorize_fixedchar"<?php if($mode=="colorize_fixedchar") echo " checked"; ?>>Colorize using character<input type="text" maxlength="1" size="1" name="fixed_char" value="<?php echo $fixed_char; ?>">
                    </td>
                </tr>
                <tr>
                    <td><b>Image</b></td>
                    <td><b>Quality</b></td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>
                        <select name="image">
                            <?php
                            
while (list($key, $value) = each($images))
                            {
                                echo 
"<option value=\"$value\"";
                                if (
$image == $value) echo " selected";
                                echo 
">$value</option>";
                            }
                            
?>
                        </select>
                    </td>
                    <td>
                        <select name="quality">
                            <?php
                            
for ($i = 1; $i <= 5; $i++)
                            {
                                echo 
"<option value=\"$i\"";
                                if (
$quality == $i) echo " selected";
                                echo 
">$i</option>";
                            }
                            
?>
                        </select>
                    </td>
                    <td align="right">
                        <input type="submit" value="Render">
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td colspan="4" align="center">Written by <a href="http://www.sebastian-r.de">sebastian r.</a> | <a href="index.phps">View Source</a></td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</form>
<span class="image">
<?php
// Load image
$im = imagecreatefrompng($imagefolder.$image);

// Get Image size
$width  = imagesx($im);
$height = imagesy($im);

// Y
for ($y = 0; $y < $height; $y+=$quality)
{
    
// X
    
for ($x = 0; $x < $width; $x+=$quality)
    {
        
// RGB Value of current pixel (Array)
        
$rgb = imagecolorsforindex($im, imagecolorat($im, $x, $y));

        
// Rounded Brightness
        
$brightness = $rgb["red"] + $rgb["green"] + $rgb["blue"];

        
// Choose replacing character
        
$replace_character_id = round($brightness / 100) + 1;

        if (
$mode=="colorize")
        {
            echo 
"<font color=\"#".hexColor($rgb)."\">".$replace_characters[$replace_character_id]."</font>";
        }
        else if (
$mode=="colorize_fixedchar")
        {
            echo 
"<font color=\"#".hexColor($rgb)."\">".$fixed_char."</font>";
        }
        else
        {
            echo 
$replace_characters[$replace_character_id];
        }
    }
    echo 
"<br>\n";
}

ImageDestroy($im);
?>
</span>
<p>
Original file<br>
<img src="<?php echo $imagefolder.$image; ?>">
</p>
</div>
</body>
</html>