how to define height and width image befor loading like the lightbox plugin?

how to define height and width image befor loading like the lightbox plugin?

Hello...

how to define height and width of image before loading Like lightbox?

Some tutorials are that, they will get the  image as a tmp or chach, then measure its length and width. But this method is delayed if the file is larg! 
The length and width of the photo must be obtained before loading like the lightbox plugin.

please guide me.
Thanks