img2table converts JPG/PNG into HTML table to render in browser.
Perhaps the only IE6 compatible embed image (But who cares about IE6 nowadays anyway?)
Perfect way to waste disk space, memory and cpu resources!
The PHP implementation:
<?php
$filename = 'original.png';
$pathinfo = pathinfo($filename);
if ($pathinfo['extension'] == 'png') {
$image = imagecreatefrompng($filename);
} else if ($pathinfo['extension'] == 'jpg' || $pathinfo['extension'] == 'jpeg') {
$image = imagecreatefromjpeg($filename);
}
if (!$image) die('Invalid image');
$size = getimagesize($filename);
$width = $size[0];
$height = $size[1];
$pixel_size = 16;
?>
<table cellpadding="0" cellspacing="0" border="0">
<?php for ($y = 0; $y < $height; $y += 1) { ?>
<tr>
<?php for ($x = 0; $x < $width; $x += 1) { ?>
<td width="<?php echo $pixel_size?>" height="<?php echo $pixel_size?>" style="background-color: #<?php echo str_pad(dechex(imagecolorat($image, $x, $y)), 6, '0', STR_PAD_LEFT);?>"></td>
<?php } ?>
</tr>
<?php } ?>
</table>
Result: 252 bytes PNG converted into 18,204 bytes HTML (7223% bigger)
Cool? No… Just a quick idea for fun 😀