views:

271

answers:

2

I've got a java servlet which is hitting this bug when down-scaling images...

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5101502

I'm trying to work out the best way to work around it and would appreciate any ideas from the community.

Thanks, Steve

A: 

You might want to use the Java Advanced Imaging (JAI) API. An example of how to scale an image using JAI can be found here.

entzik
It would be simpler to use ImageMagick.It takes quite some times to learn JAI and to be able to write effective code with it.
Alexandre Victoor
+3  A: 

Image scaling with Java can be surprisingly complicated - I ran into lots of reproducable JVM crashes when doing batch processing, which are not related to your bug though. In the end I ended up using the external command line tool 'convert' from ImageMagick, available for the relevant platforms. Simply call it with Runtime.exec(.) and the appropriate parameters. Might be even faster than a real Java solution, but this is certainly not a good solution for all apps.

the.duckman