Question

I want to do the following with a folder full of images. The images are normally .jpg but it would be better being able to use any image format.

  • load an image
  • crop a rectangle (x, y, width, length)
  • resize cropped section (finalWidth, finalLength)
  • save cropped and resized section as a new image in another folder.

I am new to JAI, could somebody please explain step by step?

Thank you very much!

Was it helpful?

Solution

katu, for what its worth, imgscalr will do all of this for you significantly easier than using JAI (single, static, method calls to perform all these ops). You can check the class Javadoc here.

You can add this Maven entry and get started with the lib immediately (no config or complex API, just call Scalr.* methods)

<dependency>
    <groupId>org.imgscalr</groupId>
    <artifactId>imgscalr-lib</artifactId>
    <version>4.2</version>
</dependency>

OTHER TIPS

Instead of using JAI, Checkout the jquery plugin JCrop to crop images in UI and save to your folder using simple java code.Checkout the example provided here. http://www.javaservletsjspweb.in/2009/09/java-and-javascript-jcrop-jquery-plugin.html#.UK9XWOTqm8A

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top