This would be ideal, but I am not sure whether it is possible. The JavaScript is only aware of the URL of the image; it does not have access to the actual image data.
I looked up the solution and got this:
var img = document.getElementById('imageId');
var width = img.naturalWidth;
var height = img.naturalHeight;
I looked up the solution and got this:
Here is a test: