<pre> <?php $res=''; $file1 = 'tema1.txt';// Файл, в который сохраняем результат (для просмотра результата юзать только WordPad) $handle = fopen($file1,'w'); $file='s.jpg'; // Картинка, которую обрабатываем (только .jpg или .png) $i = ImageCreateFromJpeg($file); $o = ImageCreate(imagesx($i), imagesy($i)); for ($n = 0; $n < 256; $n++) { imagecolorallocate($o, $n, $n, $n); } imagecopy ($o, $i, 0, 0, 0, 0, imagesx ($i), imagesy ($i)); $lim = 256/2; echo '<pre style="font-size: 12px; letter-spacing: 0px; line-height: 80%;">'; for ($y = 0; $y < imagesy ($o); $y++) { for ($x = 0; $x < imagesx ($o); $x++) { if ((imagecolorat($o, $x, $y) & 0xFF)>$lim) { $res=' '; echo $res; fwrite ($handle,$res); } else { $res=0; echo $res; fwrite ($handle,$res); } } echo "\n"; fwrite ($handle,"\n"); } echo $res; fclose ($handle); echo "\n\n\n\n\nResults was saved in $file1.txt\n"; ?> <pre>