在Java中缩放图像的最佳方式是什么? [英] What is the best way to scale images in Java?
问题描述
我有一个用Java编写的Web应用程序(Spring,Hibernate / JPA,Struts2),用户可以上传图像并将它们存储在文件系统中。我想缩放这些图片,以便它们在网站上显示的尺寸一致。哪些库或内置函数将提供最佳结果?我会在做出决定时考虑以下标准(按此顺序):
查看 Java Image I / O API 来读取/写入图像。然后使用 AffineTransform 到resize。
另外,这里是一个使用java.awt.Image的完整示例。
I have a web application written in Java (Spring, Hibernate/JPA, Struts2) where users can upload images and store them in the file system. I would like to scale those images so that they are of a consistent size for display on the site. What libraries or built in functions will offer the best results? I will consider the following criteria in making my decision (in this order):
- Free/Open Source (essential)
- Easy to implement
- Quality of results
- Performance
- Size of executable
Have a look at the Java Image I/O API to read/write the image. Then use AffineTransform to resize.
Also, here's a complete example using java.awt.Image.
这篇关于在Java中缩放图像的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!