如何解决java图像缩放错误

时间:2021-09-17 19:43:51

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

我有一个java servlet在缩小图像时遇到这个bug ...

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

2 个解决方案

#1


3  

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.

使用Java进行图像缩放可能会非常复杂 - 在进行批处理时遇到了大量可重现的JVM崩溃,但这与您的bug无关。最后,我最终使用ImageMagick的外部命令行工具'convert',可用于相关平台。只需使用Runtime.exec(。)和相应的参数调用它。可能比真正的Java解决方案更快,但这对所有应用程序来说肯定不是一个好的解决方案。

#2


1  

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.

您可能希望使用Java Advanced Imaging(JAI)API。可以在此处找到如何使用JAI缩放图像的示例。

#1


3  

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.

使用Java进行图像缩放可能会非常复杂 - 在进行批处理时遇到了大量可重现的JVM崩溃,但这与您的bug无关。最后,我最终使用ImageMagick的外部命令行工具'convert',可用于相关平台。只需使用Runtime.exec(。)和相应的参数调用它。可能比真正的Java解决方案更快,但这对所有应用程序来说肯定不是一个好的解决方案。

#2


1  

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.

您可能希望使用Java Advanced Imaging(JAI)API。可以在此处找到如何使用JAI缩放图像的示例。