The height is readable provided that the image has loaded.
If you load into an <img> tag, the true dimensions are overridden by the height/width attributes if set.
If you need to get true dimensions under any circumstances, load into an Image() object and use its onload event to read or signal the readability of dimensions.
Install your onload event handler before applying the src property.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!