Image resizing in JAI vs. ImageMagick
Part of the functionality of the cacheing server application is the dynamic and on-the-fly resizing of images to whatever dimensions are required by the client.
I wrote the first version of the image resizing code using Java Advanced Imaging (JAI), but it is apparent that the quality of the resized images wasn't quite good. I tried setting JAI to use bicubic interpolation (InterpolationBicubic and InterpolationBicubic2) instead of the default nearest-neighbour (InterpolationNearest) method. Still produced inconsistent results.
I had looked at using ImageMagick, using the java JMagick bridge, but that was just plain funky.. It relies on a JNI bridge that apparently doesn't compile well.I decided to try an ImageMagick solution using java's Runtime.exec() - and it works perfectly. Image quality is much better. The memory issues we were seeing with JAI disappeared (JAI was barfing on Very Large Images, where ImageMagick chews through them with ease). The downside is that it takes considerably longer to process the resized images, and since ImageMagick can only work with local files (not URLs), I have to download the image from the web each time I want to process it.


0 Comments:
Post a Comment
<< Home