是否有用于生成缩略图的java库? [英] Are there any java library for thumbnails generation?

查看:125
本文介绍了是否有用于生成缩略图的java库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些足够聪明的缩略图生成库才能在我的java应用程序中使用它。我在这里找到了相应的代码,但我不确定可能的许可问题。

I need some smart enough thumbnail generation lib to use it in my java app. I've found appropriate code here but I'm not sure about possible licensing issues.

是否有任何免费的适当库?

Are there any free appropriate libraries?

推荐答案

如果您拆分任务创建缩略图分为三步,加载图像,缩放图像和保存图像,您可以使用标准Java API。您可以使用 javax.imageio.ImageIO 中的静态实用程序方法来加载和保存图像,并使用 Image#getScaledInstance(...)调整原始图像的大小。由于 Image ,您从获取getScaledInstance 不是 BufferedImage ,你必须创建一个具有正确大小的新 BufferedImage 并将缩放后的图像绘制到新的 BufferedImage 中,然后才可以使用ImageIO保存它。

If you split the task "create thumbnail" into three steps, "load image", "scale image" and "save image", you can do it with the standard Java API. You can use the static utility methods in javax.imageio.ImageIO to load and save images and use Image#getScaledInstance(...) to resize the original image. Since the Image you get from getScaledInstance is not a BufferedImage, you have to create a new BufferedImage with the correct size and paint the scaled image into the new BufferedImage before you can use ImageIO to save it.

这篇关于是否有用于生成缩略图的java库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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