tags:

views:

337

answers:

3

I'm attempting to encode a large quantity of BufferedImages to JPEG using the ImageWriter class in javax.imageio. Unfortunately, the encoding operation is quite slow (about 80 to 250 ms per image, not including writing to disk.) This encoding stage ends up being the slowest part of my app, so I'm hoping to optimize it.

Does anyone know of an alternative to the ImageIO package that may be faster?

+1  A: 

You could look into JAI. This guy seemed to have success with TIFFs.

SB
+2  A: 

ImageMagick may work. There are various Java wrappers for ImageMagick, which is an image manipulation library of outstanding quality (and speed).

JMagick is one such wrapper, there are other ones:

http://www.jmagick.org/index.html

Then some people advice using ProcessBuilder to directly make "native" calls for apparently the perfs are better and there's less risk of crashes (the ImageMagick wrappers may not be that great from a performances and memory usage point of view).

If speed and JPEG quality are an issue, then you can't go much wrong with ImageMagick: it's up to you to see if you prefer to use a wrapper or directly calling the ImageMagick executables from your Java program.

Now of course this would only work if writing a lossless file from your app (say PNG files) is fast enough.

Webinator
A: 

http://www.chrfr.de/software/PNG.java is an option for generating PNG images.