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?
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With