[UPHPU] Tables rock!

Matthew Frederico mfrederico at gmail.com
Tue Jun 26 12:21:14 MDT 2007


There is a program for doing this:
<?php

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";
        }
    }
}

$img = imagecreatefromjpeg($argv[1]);
imageToHTML($img);

?>

Usage:
     /usr/bin/php image2html.php myimage.jpg > myimage.html

Enjoy!

-- 
-- 
-- Matthew Frederico


More information about the UPHPU mailing list