Posted by: Morten Nobel-Jørgensen | March 22, 2009

Improving image resizing quality in Java

This blog will describe some of the major changes and improvements in the Java Image Scaling Library, since my blog post Downscaling images in Java. A special thanks to Heinz Doerr who helped with many of the improvements.

Improving the sharpness

Even though ResampleOp class already improved the sharpness compared to the MultiStepRescaleOp class, the result may not be as sharp as you wanted it to be.

A technique used commonly used for improving the sharpness after scaling a image, is to add a unsharpen mask after rescaling. A unsharpen mask is a image filter that is used to sharpen an image (for more details on the technique read the Wikipedia article: Unsharpen mask).
The image scaling library uses the unsharpen mask from the JH Labs filter collection.

The unsharpen mask in action

Faster, better and more

The performance of the ResampleOp is now around the same as the MultiStepRescaleOp (bicubic), but in more memory consuming, so you shouldn’t use ResampleOp in all scenarios.

The library is no longer limited to handle only 3 channel images, but supports all of the image types of BufferedImage (such as grayscale, ARGB).
Best of all the overall quality of the scaling is improved.

Absolute and relative resizing

The last feature I will mention, is the added support for absolute and relative resizing. The class DimensionConstrain helps you scale images in the right format.

This class is helpful when scaling photos that may be either horizontal or vertical. Let’s say we want to rescale some photos to fit within 200×150 (horizontal) or 150×200 (vertical). We simply create a DimensionConstrain using DimensionConstrain.createMaxDimensionNoOrientation(150,200);

This also maintains the aspect radio of the image, so if I tried to rescale a 600×300 image, the result would be a 200×100 image.


The image scaling library provides a simple way to do high quality scaling in Java.
Find more details on the project’s homepage, that also contain downloadable binaries, source code and a small wiki.
The project is released under LGPL.



  1. Please send me a complete sample code for scaling the image using Java-Image-Scaling


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: