%#
%# imgsize - given a absolute (URL) path to an image, return the width & height
%#	     caching the results if possible
%# example: ($w, $h) = $m->comp('m/imgsize', '/pics/foo.gif');
%#
<%perl>
    my ($path, $wh, $o);

    $path = "$ENV{DOCUMENT_ROOT}$_[0]";

    if (($o = $m->cache->get_object($path)) && 
	    $o->get_created_at > (stat($path))[9]) {
	$wh = $o->get_data;
    } else {
	$wh = [ imgsize($path) ];
	$m->cache->set($path, $wh);
    }

    return @$wh;
</%perl>
