Click to See Complete Forum and Search --> : Image size


Unrealkin
07-16-2003, 04:53 AM
Is there any way to get the real size (width,height) of an image? Using following code when the second image has different dimensions than first one I can't get the real size but only some kind of "rescaled" values.

var tmp = new Image();
...
tmp.src = "image1.jpg"
x = tmp.width;
y = tmp.height;
...
document.images['pict'] = tmp.src
...
tmp.src = "image2.jpg"
x = tmp.width; // x<>real width of image2.jpg!
y = tmp.height; // y<>real height of image2.jpg!
...
document.images['pict'] = tmp.src

cacalex
07-16-2003, 07:55 AM
I do believe tht something like this should work :

originalW=parseInt(1stImg.style.width);
originalH=parseInt(1stImg.style.height);