Extract Width and Height of image



Hello,
I've created a Unordered list with images using the Javascript DOM,
and i want to set up the width and height attributes of the image...
The problem is that most images vary in size.
Here's my question:
Knowing the filepath of the image, is it possible to extract the width
and height? If yes, how...

Thanks
Marco

....
var ul = document.createElement('ul');

for(var i=0; i<lstThumbnail.length; i++)
{
var path = lstThumbnail[i].path;

var li = document.createElement('li');
var a = document.createElement('a');

//assign 'href' attribute to element a
a.setAttribute('href', '#');

//create img element, assign the attributes: src, alt, width,
height
var img = document.createElement('img');
img.setAttribute('src', path);
img.setAttribute('alt', noimageTxt);

img.setAttribute('width', ???); <--- EXTRACT WIDTH AUTOMATIC
img.setAttribute('height', ???); <--- EXTRACT HEIGHT AUTOMATIC

//add <img> to <a>
a.appendChild(img);

//add <a> <li>
li.appendChild(a);

//add <li> to <ul>
ul.appendChild(li);
}
....

.



Relevant Pages

  • Re: ff event problem
    ... event although i assign the top nav bar events the same way. ... just to switch images, just to replace images. ... var contentdiv = document.getElementById; ... best (general recommendation; preferable recommendation) is to avoid having function calling other functions: doing that avoids problems and code maintenance. ...
    (comp.lang.javascript)
  • Re: javaScript and Ajax - IE7
    ... That's positive as all of the images should be in the document. ... The problem is IE7 uses a different DLL for xmlhttp in IE7. ... var xmlhttp = null; ...
    (comp.lang.javascript)
  • Re: Picture Slideshow
    ... paste back into the code fragment box. ... paste the code snippet in a Notepad text file, along with the URL to where I ... Autoplay on load as images will not start to cycle through. ... var preloadedimages=new Array ...
    (microsoft.public.publisher.webdesign)
  • Re: Picture Slideshow
    ... But maybe Publisher has a method of saving snippets - DavidF would ... know more abt it (I'm out in the field without Publisher at the moment). ... Autoplay on load as images will not start to cycle through. ... var preloadedimages=new Array ...
    (microsoft.public.publisher.webdesign)
  • Re: background image
    ... *background* images here), this is only going to work in Internet ... its DOM which provides Microsoft Filters). ... var preLoad = new Array ... // if MS Filters are supported, initialize the transition effect ...
    (comp.lang.javascript)