Link

Image processing in Java

JDeli is able to process image files or images in memory. Multiple processing operations can be applied together with the convert or process methods.

Process an image file

JDeli.convert(File inputFile, File outputFile, ImageProcessingOperations operations);

JDeli can also convert between different image file formats at the same time.

View Javadoc on JDeli.convert

Process a BufferedImage

This can be done two ways:

Using the process method in JDeli

image = JDeli.process(ImageProcessingOperations operations, BufferedImage image);

View Javadoc on JDeli.process

or

Using the apply method in ImageProcessingOperations

image = operations.apply(BufferedImage image);

ImageProcessingOperations class

This class provides multiple image processing operations and an interface to add your own custom operations. Multiple operations can be added and will execute in that order.

Create an instance and pass into the JDeli process or convert methods.

Example 1 - Create a set of processing operations

ImageProcessingOperations operations = new ImageProcessingOperations();
operations.scale(1f);
operations.custom(new MyCustomProcess());
operations.rotate(90); //units are degrees

Example 2 - Chain a set of processing operations

ImageProcessingOperations operations = new ImageProcessingOperations()
.scale(1f)
.custom(new MyCustomProcess())
.rotate(90);

Example 3 - undoing and redoing operations

operations.undo(); // remove last operation added
operations.redo(); // re-add last operation removed

Example 4 - Implement a custom operation

private class MyCustomImageOperation implements ImageOperation {

    private Object myArgs;

    public MyCustomImageOperations(Object myArgs) {

        this.myArgs = myArgs;
    }

    @Override
    public BufferedImage apply(BufferedImage image) {

        //process code here
        return image;
    }
}

ImageProcessingOperations operations = 
new ImageProcessingOperations(new MyCustomImageOperation(myArgs));

View Javadoc on process package


Start Your Free Trial


Customer Downloads