I am trying to make a preloader with jquery.Can somebody please tell me how early we can get the width and height of an image so I can place the preloader.gif at the middle of the actual image with absolute positioning?

In other word I want to call a function as soon as image width and height are set.How to do it?Is it possible?