Per poterla misurare l'immagine deve esser stata caricata nel browser.
prova cosi' (non l'ho provato)
codice:
function popup(url, title) {
    var thisspan = eval("document.getElementById('popup').style")
    thisspan.visibility="visible";
    var imgs = new Image();
    
	imgs.src = url;
    imgs.onload = function() {
        var W=(imgs.width);
        var H=(imgs.height);
		output = "<div class=\"color_div\" style=\"width:"+ (W+30)+"px\">";
		output += "<a class=\"link\" alt=\"Clicca sull\'immagine per chiudere\" style='cursor:"+ pointer +"' onclick=\"closegallery()\">";
	    output += "<img src='"+ url +"' title='"+ url +"' style=\"width:"+ W +"px;height:"+ H +"px;margin:"+ borderimg +";\"><\/a>";
	    output += "<p>" + title + " (" + W + " - " + H + ")<\/p><\/div>";
		document.getElementById('popup').innerHTML = output;
	}
}