|
Posted by ZeldorBlat on 06/03/07 23:22
On Jun 3, 6:52 pm, Andy Hassall <a...@andyh.co.uk> wrote:
> On Sun, 3 Jun 2007 18:04:03 -0400, "Skeleton Man" <inva...@guestwho.com> wrote:
> >I was thinking.. wouldn't it be cool if you could take an image (jpeg) and
> >redraw the entire thing in HTML ? In theory you could parse the image to
> >create an array containing the RGB value for every pixel and then print this
> >out as a series of 1 pixel wide DIV's with the background color set to the
> >pixel colour.
>
> >I realise this would result in a massive document (likely several mb) with
> >millions of layers, but has anyone ever tried something like this ? I know
> >you can get programs to convert jpeg to ascii art, so I can't be too far off
> >in my thinking..
>
> Yes, been done before, one of many examples:http://www.eggheadcafe.com/articles/Image2Html/default.aspx
>
> It's a fairly pointless exercise though.
>
> --
> Andy Hassall :: a...@andyh.co.uk ::http://www.andyh.co.ukhttp://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool
Pretty pointless and really not that difficult, either:
function imageToHTML($img) {
$width = imagesx($img);
$height = imagesy($img);
for($i = 0; $i < $height; $i++) {
for($j = 0; $j < $width; $j++) {
$color = str_pad(base_convert(imagecolorat($img, $j, $i),
10, 16), 6, '0', STR_PAD_LEFT);
echo '<div style="position: absolute; background-color:
#' . $color . '; height: 1px; width: 1px; top: ' . $i . 'px; left: ' .
$j . 'px;"></div>' . "\n";
}
}
}
Navigation:
[Reply to this message]
|