Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Image Scaling Library

I have searched and found a few image scaling libraries for Java. But not sure which one to go with. I need to generate thumbnails from the image uploaded by server.

It would be great if you can tell which one's good and bad.

The list I have is:

  • JMagick
  • im4java
  • Thumbnailator
  • java-image-scaling
  • JAI
like image 391
Mukun Avatar asked Jan 21 '12 09:01

Mukun


1 Answers

For my simple needs, Thumbnailator was perfect. Small lib; fluent, clean, well-documented API.

In my case, it was just "net.coobird" % "thumbnailator" % "0.4.8" dependency and:

//..
Thumbnails.of(originalFile)
      .size(300, 300) 
      .toFile(thumbnailFile)
//.. 

and done. Basically it’s a friendly wrapper on top of the Java 2D APIs. Useful for specific (thumbnailin') needs; no learning curve.


Unless you really need to do some heavy-lifting with images, I'd be wary of depending on an external binary (ImageMagick and wrappers like JMagick), which would add complexity and moving parts into the setup. Especially if your stack is something like mine: Scala/Java app running on Heroku. There’s stuff like heroku-buildpack-imagemagick-cedar-14, yes, but a simple dependency bundled with the app is infinitely cleaner.

like image 58
Jonik Avatar answered Sep 30 '22 08:09

Jonik