how to workaround a java image scaling bug

不问归期 提交于 2019-12-13 03:56:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!