<?php 

// Графический редактор ;)

$width  70// точек по ширине
$height 50// точек по высоте
$size   10// размер точки

if (isset($_POST['subm'])) {
    
$im imagecreate($width$height);
    
$fon_color imagecolorallocate($im255255255);
    
$ris_color imagecolorallocate($im051204);
    foreach (
$_POST['subm'] as $xy) {
        
$xy explode('-'$xy);
        
imagesetpixel($im$xy['1'], $xy['0'], $ris_color);
    }
    
$im2 imagecreate($width*$size$height*$size);
    
imagecopyresized($im2$im0000$width*$size$height*$size$width$height);
    
imagerectangle($im200$width*$size-1$height*$size-1$ris_color);
    
header('Content-Type: image/png');
    
header('Content-Disposition: attachment; filename="img.png";');
    
imagepng($im2);
    exit;
}

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

<html>
<head>
 <meta http-equiv="content-type" content="text/html; charset=windows-1251">
 <title>Графический редактор</title>
 <script type="text/javascript">
     var brush = false;
     function add_hid(idn2, nam) {
         var idn = idn2.getAttribute('id');
         if (!document.getElementById('new'+idn) && brush) {
            var newH   = document.createElement('input');
            newH.name  = nam+'[]';
            newH.id    = 'new'+idn;
            newH.type  = 'hidden';
            newH.value = idn;
            document.getElementById('newF').appendChild(newH);
            document.getElementById(idn).style.background = 'RGB(0, 51, 204)';
         }
     }
     function create_holst(width, height) {
         var holstTable = document.getElementById('holst');
         for (var i = 0; i < height; i++) {
             var holstRow = holstTable.insertRow(i);
             for (var ii = 0; ii < width; ii++) {
                 var holstCell = holstRow.insertCell(ii);
                 holstCell.style.background = 'RGB(255, 255, 255)'; // для ie хм...
                 holstCell.setAttribute('id', i+'-'+ii);
                 holstCell.onmouseover = function() {
                     add_hid(this, 'subm');
                 }
             }
         }
     }
 </script>
 <style type="text/css">
     #holst {
         border: 1px solid RGB(0, 51, 204);
         border-collapse: collapse;
         cursor: crosshair;
     }
     #holst td {
         padding: 0px;
         width: <?php echo $size?>px;
         height: <?php echo $size?>px;
     }
 </style>
</head>
<body onLoad="create_holst(<?php echo $width?><?php echo $height?>);">

 <h3>Графический редактор</h3>
 <table id='holst' onMouseDown="brush=true;" onMouseUp="brush=false"></table>
 <form action="" method=post id=newF><input type=submit value='сохранить'></form>

</body>
</html>