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

Image.resize()

Sets the height and width of an image to new values.

Syntax
imageObject.resize(widthNumber, heigthNumber)

The widthNumber and heightNumber arguments need to be integers, so be careful to round the new values eventually.

In case of a GIF image always reduce the image to 256 colors after resizing by using the reduceColors() function.

Example
var img = new Image("http://helma.org/images/original.jpg");
res.write('<img src="/images/original.jpg">');

A picture showing two funny people

var factor = 0.66;
var wd = Math.round(img.getWidth() * factor);
var ht = Math.round(img.getHeight() * factor);
img.resize(wd, ht);
img.saveAs("/www/images/processed.jpg");

res.write('<img src="/images/processed.jpg">');

A picture showing two funny people


... comment


Page last modified on 2002-07-16 17:00 by tobi