Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // JPEG 2 ASCII
- $in = 'test.jpg';
- $out = 'test.html';
- $buf = '';
- $gd = imagecreatefromjpeg($in);
- $w = imagesx($gd);
- $h = imagesy($gd);
- for($y=0; $y<$h; $y++){
- for($x=0; $x<$w; $x++){
- $rgb = imagecolorat($gd, $x, $y);
- $r = ($rgb >> 16) & 0xFF;
- $g = ($rgb >> 8) & 0xFF;
- $b = $rgb & 0xFF;
- $buf .= "<span style=\"color:rgb({$r},{$g},{$b});\">#</span>";
- if($w === $x+1){
- $buf .= '<br>';
- }
- }
- }
- echo "<div style=\"line-height:1px;font-size:1px;\">{$buf}</div>";
Add Comment
Please, Sign In to add comment