ImageToText - img2txt.php
Cerca
 











img2txt.php

Caricato da: A_butta
Scarica il programma completo

  1. <?
  2. function img2txt($filename,$type)
  3. {
  4. echo '<font size="-3">';
  5.   switch ($type) {
  6.     case 'png' : $im = imagecreatefrompng($filename);
  7.                   break;
  8.     case 'gif' : $im = imagecreatefromgif($filename);
  9.                   break;
  10.     default    : $im = imagecreatefromjpeg($filename);
  11.    
  12.   }  
  13.   $size = getimagesize($filename);
  14.   $w = $size[0];
  15.   $h = $size[1];
  16.   for ($k=0;$k<=($h-6);$k+=6)
  17.   {
  18.     for ($i=0;$i<=($w-3); $i+=3)
  19.     {
  20.     $n = rand(0,1);
  21.     if (!$n)
  22.     {
  23.       for ($j=0;$j<=2;$j++)
  24.         for ($y=0;$y<=5;$y++)
  25.         {
  26.           $rgb = imagecolorat($im, $i+$j, $k+$y);
  27.           $r[$j][$y] = ($rgb >> 16) & 0xFF;
  28.           $g[$j][$y] = ($rgb >> 8) & 0xFF;
  29.           $b[$j][$y] = $rgb & 0xFF;
  30.           $sommaR += $r[$j][$y];
  31.           $sommaG += $g[$j][$y];
  32.           $sommaB += $b[$j][$y];
  33.         }
  34.       $R = $sommaR / 18;
  35.       $G = $sommaG / 18;
  36.       $B = $sommaB / 18;
  37.       $sommaR = 0;
  38.       $sommaG = 0;
  39.       $sommaB = 0;
  40.       echo "<span style='color: rgb(".floor($R).",".floor($G).",".floor($B).")';>0</span>";  
  41.     }
  42.     else
  43.     {
  44.       for ($j=0;$j<=4;$j++)
  45.         for ($y=0;$y<=5;$y++)
  46.         {
  47.           $rgb = imagecolorat($im, $i+$j, $k+$y);
  48.           $r[$j][$y] = ($rgb >> 16) & 0xFF;
  49.           $g[$j][$y] = ($rgb >> 8) & 0xFF;
  50.           $b[$j][$y] = $rgb & 0xFF;
  51.           $sommaR += $r[$j][$y];
  52.           $sommaG += $g[$j][$y];
  53.           $sommaB += $b[$j][$y];
  54.         }
  55.       $R = $sommaR / 30;
  56.       $G = $sommaG / 30;
  57.       $B = $sommaB / 30;
  58.       $sommaR = 0;
  59.       $sommaG = 0;
  60.       $sommaB = 0;
  61.       echo "<span style='color: rgb(".floor($R).",".floor($G).",".floor($B).")';>1</span>";  
  62.     }
  63.     }
  64.     echo '<br />';
  65.   }
  66. echo '</font>';
  67. }
  68. ?>
 

Creative Commons License
Il layout di questo sito è concesso sotto licenza Creative Commons.
Per maggiori informazioni sulle licenze dei contenuti del sito, clicca.