问题
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
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/113776/how-to-workaround-a-java-image-scaling-bug