<?
$factor = (int)$_POST
['factor'];
$usetable = $_POST['table'];
$file = $_POST['file'];
$act = $_GET['act'];
$fileex = $_POST['fileex'];
echo "<form action=\"".$_SERVER
['PHP_SELF']."?act=make\"
method=\"post\">
<table><tr>
<td>Адрес файла:</td><td><input
name=\"file\" type=\"text\"
value=\"\"></td></tr>
<tr><td>Файл с инета
\"fileex\" type=\"checkbox\"
value=\"ON\"></td></tr>
<tr><td>Погрешность цвета</
td><td><input name=\"factor\"
type=\"text\" value=\"\"></
td></tr>
<tr><td>Использовать таблицу
<input name=\"table\" type=
\"checkbox\" value=\"OFF\"></
td><td>Если вы не используете
таблицу, уменьшите
маштабирование в браузере до
50% ))</td></tr>
</table>
<input type=\"submit\" value=
\"JPG => ASCII\">
</form>";
if($act =='make')
{
($format))-1];
if($file == '')
{
echo "<br />Вы не ввели адрес
файла!";
}
AND !$fileex)
{
echo "<br />Файл
несуществует!";
}
elseif(($format != 'jpg') AND
($format != 'jpeg'))
{
echo "<br />Неверный формат
файла. Поддерживается только
JPG!";
}
else
{
($file);
$orig_x = (int)$size[0]/2;
$orig_y = (int)$size[1]/3;
if($usetable)
{$str='<table><tr>';}else
{$str='';}
for($y=1;$y<=$orig_y;$y++)
{
for($x=1;$x<=$orig_x;$x++)
{
$str.= quatro($img,$x,$y,$str,
$factor,$usetable);
}
if($usetable){$str.="</
tr><tr>";}else{$str.="<br/>";}
}
if($usetable){echo "<font
style=\"font-family: Courier
\">".$str."</font></table>";}
else{echo "<font style=\"font-
family: Courier\">".$str;}
}
}
function quatro($img,$x,$y,
$str,$factor,$usetable)
{
$x = $x*2;
$y = $y*3;
for($q_x=0;$q_x<2;$q_x++)
{
for($q_y=0;$q_y<3;$q_y++)
{
$q_x, $y+$q_y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$pixel_total = $r + $g + $b;
if ($pixel_total > (((255 +
$factor) / 2) * 3)) {
$hex.=0;
} else {
$hex.=1;
}
}
}
return sectorToASCII($hex,
$usetable);
}
function sectorToASCII($hex,
$usetable)
{
$char[000001] = ',';
$char[000010] = '.';
$char[000011] = 'i';
$char[000100] = '\'';
$char[000101] = ':';
$char[000110] = 'l';
$char[000111] = '!';
$char[001000] = '.';
$char[001001] = '_';
$char[001010] = '/';
$char[001011] = '';
$char[001100] = '/';
$char[001101] = ';';
$char[001110] = '/';
$char[001111] = 'J';
$char[010000] = '`';
$char[010001] = chr(0x5C); $char[010010] = '-';
$char[010011] = '';
$char[010100] = '/';
$char[010101] = '<';
$char[010110] = '';
$char[010111] = '<';
$char[011000] = 'i';
$char[011001] = '';
$char[011010] = 'в';
$char[011011] = '*';
$char[011100] = '/';
$char[011101] = 'B';
$char[011110] = '&';
$char[011111] = '';
$char[100000] = '`';
$char[100001] = chr(0x5C); $char[100010] = chr(0x5C); $char[100011] = chr(0x5C); $char[100100] = '{';
$char[100101] = '';
$char[100110] = chr(0x5C); $char[100111] = '7';
$char[101000] = ':';
$char[101001] = '';
$char[101010] = '>';
$char[101011] = 'Э';
$char[101100] = '';
$char[101101] = '=';
$char[101110] = '?';
$char[101111] = ']';
$char[110000] = '¦';
$char[110001] = chr(0x5C); $char[110010] = '';
$char[110011] = '%';
$char[110100] = '';
$char[110101] = 'г';
$char[110110] = '"';
$char[110111] = '9';
$char[111000] = 'I';
$char[111001] = 'L';
$char[111010] = '>';
$char[111011] = '6';
$char[111100] = 'В';
$char[111101] = '[';
$char[111110] = '@';
$char[111111] = '#';
if($usetable)
{
if($char[$hex]=='')$char
[$hex]=' ';
return "<td>".$char[$hex]."</
td>";
}
else
{
if($char[$hex]=='')$char
[$hex]='  ';
return $char[$hex];
}
}
?>