As someone already suggested, you should let your image load w/o any width applied to it and record it. however, you don't need any server side scripting to do it, you can:
- Hide original image so it won't 'blink' or do anything funny with page layout before resize (this is probably optional)
- Let it load, and record its dimensions onload
- When load is ready, resize it
- Finally, you can get both dimensions
My code in jQuery will do it for you:
<img id="myImage" style="display:none;" src="http://www.google.com/intl/en_ALL/images/logo.gif" alt="Google!" />
<div id="status"></div>
<script type="text/javascript">
var ImageModifier = {
WIDTH: 400,
Original: null,
Init: function() {
$(function(){
$('#myImage').load(function(){
//remember original size
ImageModifier.Original = { width: $(this).width(), height: $(this).height()}
//Resize the image
$(this).css("width", ImageModifier.WIDTH);
//print info after resize
ImageModifier.Info(this);
//show the image
$(this).css("display", "block");
});
});
},
Info: function(obj){
$('#status').append("Original Size: [" + ImageModifier.Original.width + "x" + ImageModifier.Original.height +"]" +
"<br />Current size: [" + $(obj).width() + "x" + $(obj).height() +"]<br />");
}
}
ImageModifier.Init();
</script>