Are there any java library for thumbnails generation? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answere开发者_开发技巧d with facts and citations.
Closed 7 years ago.
Improve this questionI 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?
Try thumbnailator: http://code.google.com/p/thumbnailator/. All the code you need to add is:
Thumbnails.of(new File("path/to/directory").listFiles())
.size(640, 480)
.outputFormat("jpg")
.toFiles(Rename.PREFIX_DOT_THUMBNAIL);
It's also fast: https://github.com/coobird/thumbnailator/wiki/Comparison
Good luck
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.
For creating thumbnails using API methodology, Scalr.resize("your arguments") would be the best one. Also thumbanilator is an option where you dont have to waste much time of yours in understanding, just call the respective method and enjoy with your output thumbnail. Performance/Quality wise Scalr is best. Quality wise thumbnailator is ok.
I've checked his site and there's no mention of license. That could mean trouble. At least in Italy where I live because if there's no explicit permission you can't use works that are not yours.
I would suggest to read this question: Open source Java library to produce webpage thumbnails server-side
There is jmagick, a Java Implementation of the popular ImageMagick framework.
精彩评论