Helma logo
helma.org » Home > Stories > Image.getInfo()

Image.getInfo()

Returns an ImageInfo object for an image.

Syntax
Image.getInfo(path)
Image.getInfo(url)
Image.getInfo(byteArray)
Image.getInfo(inputStream)

This function allows to retrieve image properties such as width, height and MIME type without the need to fully decode the image.

Example

var info = Image.getInfo("http://helma.org/images/hop.gif");
if (info) {
    res.writeln('width: ' + info.width);
    res.writeln('height: ' + info.height);
}

width: 174
height: 35
Note that in contrast to the other Image function, this is called on the constructor rather than on a decoded Image object. This is because the purpose of this function is to avoid the expensive image decoding process if we're just interested in some of the image's properties.

The function returns an instance of Marco Schmidt's ImageInfo object if the image could be read, or null if the image couldn't be read. See the ImageInfo API documentation for the full set of methods. (Remember that you can getters as properties in Rhino as shown in the example above.)


... comment


Page last modified on 2004-07-12 17:39 by hns