Wednesday, June 25, 2008

High quality image resizing in Java

I tried a dozens of different queries to learn about image resizing (or thumbnail creation) in java. Many helpful souls have written excellent articles on this topic. But, unfortunately, none of them offered really crisp quality. My benchmark for quality was resizing done with "convert" command of ImageMagick, which I think does a scarily good job.

Somebody also figured that this is not a trivial task. Hence they put commercial software for the same. ImageResize4J solves this simple problem, but unfortunately their minimum license fees of $150 is tad higher for me. To benchmark their results with various other techniques (sing JAI, Java2D, ..) they have put up the code for other techniques as well. Since I was fiddling with JAI, I picked that code and found the quality of output to be surprisingly good compared to other samples. (Obviously, their software definitely does a better job.)

It falls short of expectation on one count - image size. ImageMagick packs the punch in 4.7K, whereas the JAI takes anywhere from 7.2K to 8.4K depending on interpolation. (Bilinear interpolation gives smaller size than Bicubic.) You can play with compression ratio (0.95 in the code linked above) to a little lower say 0.9 or 0.85 to reduce the size by 25-35%. But, then you need to be cautious about a shade loss in quality.

To sum, I will buy ImageResize4J as soon as I can afford.

Labels: ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]