Skip to content

Scaling images

Ralph Niemitz edited this page May 18, 2017 · 5 revisions

Absolute scaling

Absolute scaling is resizing the image to have the given width and height. It doesn't matter if the result is proportional to the original.

This can be done with the scale(int, int) method. The parameters of this method are the new width and height of the image and optional the algorithm to use. Nearest neighbour interpolation will be used by default. The width and height of the new image must be bigger than zero.

Example:

SimpleImage orig = new SimpleImage("myImage.jpg");
SimpleImage scaled = orig.scale(600, 289);

Original:
Original

Scaled:
Scaled

Scale to fit

Scale by factor

Clone this wiki locally