|
Posted by -Lost on 06/04/07 15:31
ZeldorBlat wrote:
> 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";
> }
> }
> }
Would that function be limited to an instance where an image was created
or is it possible to use imagecreatefrompng()?
Granted, I know very little about image-related PHP. I thought I could
plug in a PNG I had (just to get a valid image resource) and I did
nothing, but crash my browser *every* time.
--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Navigation:
[Reply to this message]
|