在Java中缩放图像的最佳方式是什么? [英] What is the best way to scale images in Java?

查看:163
本文介绍了在Java中缩放图像的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Java编写的Web应用程序(Spring,Hibernate / JPA,Struts2),用户可以上传图像并将它们存储在文件系统中。我想缩放这些图片,以便它们在网站上显示的尺寸一致。哪些库或内置函数将提供最佳结果?我会在做出决定时考虑以下标准(按此顺序):


  • 自由/开源(必备)

  • 易于实施

  • 结果质量

  • 性能

  • / li>

解决方案

查看 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆