img2table – Worst abuse of HTML table

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 😀

PhoneGap 與 Cordova 的實際差異

談起跨平台手機 Apps,PhoneGap 應該算是最為人熟識的 Framework。
那 Cordova 又是啥東東?

原來是 Adobe 在 2011 年從一家小型公司手上收購了 PhoneGap。
然後又把它的 Source Code 捐獻了給 Apache 基金會成為 OSS。
但 Adobe 又保留了 PhoneGap Build 這個服務自己獨有。

從此於是乎兩者的關係曖昧不清…按照官方的說法 PhoneGap 是 Cordova 的一個 distribution。

PhoneGap is a distribution of Apache Cordova. You can think of Apache Cordova as the engine that powers PhoneGap, similar to how WebKit is the engine that powers Chrome or Safari.

Continue reading “PhoneGap 與 Cordova 的實際差異”