BLACK BURN HACKER. Powered by Blogger.

Real Money Instantly

 

Saturday, January 28, 2012

[snippet]convert JPG image to ASCII

0 comments

<?php function getext($filename) { 
    $pos = strrpos($filename,'.'); 
    $str = substr($filename, $pos); 
    return $str; } if(!isset($_POST['submit'])){ ?> 
<form action="<?echo $_SERVER['PHP_SELF'];?>" method="post"> 
    JPG img URL: <input type="text" name="image"><br> 
    <input type="submit" name="submit" value="Create"> </form> <? }else{ 
    $image = $_POST['image']; 
    $ext = getext($image); 
    if($ext == ".jpg"){ 
        $img = ImageCreateFromJpeg($image); 
    } 
    else{ 
        echo'Wrong File Type'; 
    } 
    $width = imagesx($img); 
    $height = imagesy($img); 
     
    for($h=0;$h<$height;$h++){ 
        for($w=0;$w<=$width;$w++){ 
            $rgb = ImageColorAt($img, $w, $h); 
            $r = ($rgb >> 16) & 0xFF; 
            $g = ($rgb >> 8) & 0xFF; 
            $b = $rgb & 0xFF; 
            if($w == $width){ 
                echo '<br>'; 
            }else{ 
                echo '<span style="color:rgb('.$r.','.$g.','.$b.');">#</span>'; 
            } 
        } 
    } } ?>

©2011, copyright BLACK BURN

0 comments:

Post a Comment

 

7 Years Earning Experience

The Earning Source You Can Trust