Click to See Complete Forum and Search --> : getting image size


pelegk1
05-29-2003, 08:33 AM
how can i get by code the image size that is on the
server?

khalidali63
05-29-2003, 09:49 AM
if you do not have an image reference...

var img = new Image();
img.src="/images/some.gif";

//now you can get the image size.

var imgW = img.width;
var imgH = img.height;

if you already have an image loaded on the page somewhere
in that case give that image an id attribute and reference it as follows.

var img = document.getElementBYId("imgId");
//now you can get the image size.

var imgW = img.width;
var imgH = img.height;