this code gives 0 as height and width for the first time it iterates and the second time gives the right dimensions
===

 

                                    var icon1 = new Image();
                                    icon1.src = resource;
                                    var wid1=icon1.width;
                                    var hei1=icon1.height;

This code when iterates gives 0 as width and height for the first time it iterates and for the second time it gives right dimensions