PHP / Image Manipulation / image2text
Snippet details
ID: 526
Viewed: 1504
Added: 2004-06-12
Version: unknown
Sorry no demo
This is just a fun snippet that will turn a picture into text (even colored text).
General Details
Snippet uploaded by: Aaron Campbell
Email : snippetlibrary@ezdispatch.com
Snippet By: Aaron Campbell
<!---Head--->
none
<!---Body--->
<?php
if($_GET['image']){$image = $_GET['image'];}else{echo "No Image Specified!"; exit;}
if($_GET['letter']){$letter = $_GET['letter'];}else {$letter = "#";}
//$image = "jhn.jpg";
$dim = getimagesize($image);
$im_src = imagecreatefromjpeg($image);
$width = 30;
$height = $dim[1]*$width/$dim[0];
$im = imagecreate($width, $height);
imagecopyresampled($im, $im_src, 0, 0, 0, 0, $width, $height, $dim[0], $dim[1]);
for ($x = 0; $x < $height; $x++)
{
for ($y = 0; $y < $width; $y++)
{
$color = imagecolorat($im, $y, $x);
$color = imagecolorsforindex($im, $color);
echo "<b style="color:rgb(". $color['red'] .",". $color['green'] .",". $color['blue'] .")">". $letter ."</b>";
}
echo "<br />";
}
?>
No Reviews to show
