11

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?

Roman
  • 64,384
  • 92
  • 238
  • 332

5 Answers5

24

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

Community
  • 1
  • 1
ieugen
  • 2,293
  • 2
  • 18
  • 19
  • love it! works like a charm and super easy to use. plugged into my website within minutes and am very happy with this – Peter Perháč Feb 05 '15 at 23:33
  • For easy integration with popular build tools see: [http://mvnrepository.com/artifact/net.coobird/thumbnailator](http://mvnrepository.com/artifact/net.coobird/thumbnailator) – icl7126 Feb 02 '16 at 08:50
8

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.

jarnbjo
  • 33,923
  • 7
  • 70
  • 94
2

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.

SomeDoubts
  • 137
  • 2
  • 6
0

There is jmagick, a Java Implementation of the popular ImageMagick framework.

Russ
  • 133
  • 5
  • 1
    Good idea, but suboptimal. Adding an external dependency and calling native methods via an ABI wrapper is not what a Java developer calls good solution. – gyorgyabraham Nov 20 '12 at 09:58
  • It's not really a Java implementation, it's a Java interface to the native ImageMagick libraries. – Ken Liu Apr 09 '13 at 15:31
0

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

Community
  • 1
  • 1
dierre
  • 7,140
  • 12
  • 75
  • 120