0

I have an browse area in which the user browses and enters an image.

I need to know the height and width of the image to limit it.

var img= IWDatacapture.getItem("banners/mobile-banner/mobile-content[1]/main-image");
var params = new Object();

if(img.length==undefined)
{
    var savnm = IWDatacapture.getWorkarea() + img.getValue();
    params.savnm = savnm;               
    var server = window.location.hostname;
    IWDatacapture.callServer("http://"+server+"/iw-bin/iw_cgi_wrapper.cgi/getFileSize.ipl", params,true);
}

After I make a server call, I didn't understand how to access the image's attributes.

davejal
  • 6,009
  • 10
  • 39
  • 82
Ege
  • 941
  • 4
  • 17
  • 36

1 Answers1

0

Try something like:

// Get the full image URL:

var img = IWDatacapture.getItem("banners/mobile-banner/mobile-content[1]/main-image");

// Note: I'm not sure if the following will generate the correct URL, but it should be close. Double check the "workarea" part.

var fullImagePath = "/iw/cci/meta/no-injection/iw-mount/" + IWDatacapture.getWorkarea() + img.getValue();

// Then load the image in the browser to get the dimensions:

var image = new Image();

image.onload = function(){
  var height = image.height;
  var width = image.width;

  // Whatever you want to do

}

image.src = fullImagePath;
Zaarin
  • 16
  • 2