Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any java library for thumbnails generation? [closed]

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?

like image 233
Roman Avatar asked Aug 10 '10 14:08

Roman


3 Answers

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.

like image 89
jarnbjo Avatar answered Oct 04 '22 04:10

jarnbjo


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

like image 20
ieugen Avatar answered Oct 04 '22 02:10

ieugen


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.

like image 41
SomeDoubts Avatar answered Oct 04 '22 04:10

SomeDoubts