Class ImageProcessingOperations

java.lang.Object
com.idrsolutions.image.process.ImageProcessingOperations
All Implemented Interfaces:
ImageProcessingOps

public class ImageProcessingOperations extends Object implements ImageProcessingOps
Holds a list of image processing operations and applies them in the order they were added. Each method that adds an operation returns this instance, so calls can be chained.

Example:


 ImageProcessingOperations operations = new ImageProcessingOperations()
     .blur()
     .crop(new Rectangle(0, 0, 100, 100));
 BufferedImage processedImage = operations.apply(image);
 
  • Constructor Details

    • ImageProcessingOperations

      public ImageProcessingOperations()
  • Method Details

    • apply

      public BufferedImage apply(BufferedImage image)
      Applies the chosen image operation/operations to the image.
      Specified by:
      apply in interface ImageProcessingOps
      Parameters:
      image - BufferedImage to apply the processing operation to.
      Returns:
      BufferedImage The new image.
    • blur

      Adds the blur operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the blur operation.
    • custom

      public ImageProcessingOperations custom(ImageOperation custom)
      Adds the custom operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      custom - ImageOperation to be applied
      Returns:
      This instance of ImageProcessingOperations that includes the custom operation.
    • clip

      public ImageProcessingOperations clip(Shape s, boolean clipToShape)
      Adds the clip operation to a list of operations to be applied.

      If clipToShape is true, the result is the size of the shape's bounds and keeps only the pixels inside the shape. If it is false, the result is the same size as the image, and the area inside the shape is cleared to transparent (black for images without alpha).

      Parameters:
      s - Shape to clip with, in image coordinates
      clipToShape - true to keep only the area inside the shape, false to clear it
      Returns:
      This instance of ImageProcessingOperations that includes the clip operation.
    • crop

      Adds the crop operation to a list of operations to be applied.
      Parameters:
      rec - Rectangle to crop the image to. It must lie within the image bounds.
      Returns:
      This instance of ImageProcessingOperations that includes the crop operation.
    • edgeDetection

      public ImageProcessingOperations edgeDetection()
      Adds the edge detection operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the edge detection operation.
    • emboss

      public ImageProcessingOperations emboss()
      Adds the emboss operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the emboss operation.
    • exposure

      public ImageProcessingOperations exposure(float exposure)
      Adds the exposure operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      exposure - float amount of exposure to apply
      Returns:
      This instance of ImageProcessingOperations that includes the exposure operation.
    • gaussianBlur

      public ImageProcessingOperations gaussianBlur()
      Adds the gaussian blur operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the gaussian blur operation.
    • invertColors

      public ImageProcessingOperations invertColors()
      Adds the invert colors operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the invert colors operation.
    • kernel

      public ImageProcessingOperations kernel(float[] kernel)
      Adds the Kernel operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      kernel - float[] of kernel to apply
      Returns:
      The updated ImageProcessingOperations that includes the kernel operation.
    • brighten

      public ImageProcessingOperations brighten(float percent)
      Adds the Brighten operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      percent - float percentage to brighten
      Returns:
      The updated ImageProcessingOperations that includes the brighten operation.
    • mirror

      public ImageProcessingOperations mirror(com.idrsolutions.image.process.MirrorOperations mirrorOp)
      Adds the mirror operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      mirrorOp - enum of which mirroring operation to do
      Returns:
      This instance of ImageProcessingOperations that includes the mirror operation.
    • mirror

      public ImageProcessingOperations mirror()
      Adds the mirror operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the mirror operation.
    • resizeToFit

      public ImageProcessingOperations resizeToFit(int newWidth, int newHeight)
      Adds the resize to fit operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      newWidth - Integer of new width
      newHeight - Integer of new height
      Returns:
      This instance of ImageProcessingOperations that includes the resize to fit operation.
    • resizeToHeight

      public ImageProcessingOperations resizeToHeight(int newHeight)
      Adds the resize to height operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      newHeight - Integer of new height
      Returns:
      This instance of ImageProcessingOperations that includes the resize to height operation.
    • resizeToWidth

      public ImageProcessingOperations resizeToWidth(int newWidth)
      Adds the resize to width operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      newWidth - Integer of new width
      Returns:
      This instance of ImageProcessingOperations that includes the resize to width operation.
    • rotate

      public ImageProcessingOperations rotate(double degrees)
      Adds the rotate operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      degrees - Double of degrees to rotate the image
      Returns:
      This instance of ImageProcessingOperations that includes the rotate operation.
    • scale

      public ImageProcessingOperations scale(double scaling)
      Adds the scale operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      scaling - Double of scale to apply the image
      Returns:
      This instance of ImageProcessingOperations that includes the scale operation.
    • scale

      public ImageProcessingOperations scale(double scaling, int interpolation)
      Adds the scale operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      scaling - Double of scale to be applied
      interpolation - Integer of interpolation to be applied
      Returns:
      This instance of ImageProcessingOperations that includes the scale operation.
    • sharpen

      public ImageProcessingOperations sharpen()
      Adds the sharpen operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the sharpen operation.
    • stretchToFill

      public ImageProcessingOperations stretchToFill(int newWidth, int newHeight)
      Adds the stretch to fill operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      newWidth - Integer of new width
      newHeight - Integer of new height
      Returns:
      This instance of ImageProcessingOperations that includes the stretch to fill operation.
    • superScale2x

      public ImageProcessingOperations superScale2x()
      Adds the super scale 2x operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the super scale 2x operation.
    • toARGB

      public ImageProcessingOperations toARGB()
      Adds the toARGB operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the toARGB operation.
    • toBinary

      public ImageProcessingOperations toBinary()
      Adds the toBinary operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the toBinary operation.
    • toGrayscale

      public ImageProcessingOperations toGrayscale()
      Adds the toGrayscale operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the toGrayscale operation.
    • toIndexed

      public ImageProcessingOperations toIndexed()
      Adds the toIndexed operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the toIndexed operation.
    • toRGB

      public ImageProcessingOperations toRGB()
      Adds the toRGB operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Returns:
      This instance of ImageProcessingOperations that includes the toRGB operation.
    • qualityScale

      public ImageProcessingOperations qualityScale(double scaling)
      Adds the quality scale operation to a list of operations to be applied.
      See the JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      scaling - Double of the scale to be applied
      Returns:
      This instance of ImageProcessingOperations that includes the quality scale operation.
    • thumbnail

      public ImageProcessingOperations thumbnail(int width, int height)
      Adds the thumbnail operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use.
      Parameters:
      width - Integer of the thumbnail width
      height - Integer of the thumbnail height
      Returns:
      This instance of ImageProcessingOperations that includes the thumbnail operation.
    • watermark

      public ImageProcessingOperations watermark(String text, Color color, Font font, Watermark.WatermarkPosition pos)
      Adds the watermark operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      text - String text to be displayed as watermark, '\n' will divide watermark across multiple lines
      color - Color to be used to represent text watermark
      font - font style to represent text watermark
      pos - Enum WatermarkPosition which represents the position of the Watermark for centre or fit to image position
      Returns:
      This instance of ImageProcessingOperations that includes the watermark operation.
    • watermark

      public ImageProcessingOperations watermark(String text, Color color, Font font, Watermark.WatermarkPosition pos, Rectangle rect)
      Adds the watermark operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      text - String text to be displayed as watermark, '\n' will divide watermark across multiple lines
      color - Color to be used to represent text watermark
      font - font style to represent text watermark
      pos - Enum WatermarkPosition which represents the position of the Watermark for centre, fit to image position or to the specified co-ords
      rect - Rectangle that specifies the location of the watermark when USE_SHAPE_COORDINATES is set
      Returns:
      This instance of ImageProcessingOperations that includes the watermark operation.
    • watermark

      public ImageProcessingOperations watermark(BufferedImage watermarkImage, Watermark.WatermarkPosition pos, AlphaComposite alphaComposite)
      Adds the watermark operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      watermarkImage - BufferedImage of image to watermark
      pos - Enum WatermarkPosition which represents the position of the Watermark for centre, fit to image position or to the specified co-ords
      alphaComposite - AlphaComposite to be used when applying watermark
      Returns:
      This instance of ImageProcessingOperations that includes the watermark operation.
    • watermark

      public ImageProcessingOperations watermark(Shape shape, Color color, Watermark.WatermarkPosition pos, AlphaComposite alphaComposite, Watermark.WatermarkShapeProperties properties)
      Adds the watermark operation to a list of operations to be applied.
      See JDeli tutorials for more information on how to use this processing operation.
      Parameters:
      shape - Shape to use when applying watermark
      color - Color to be used to represent text watermark
      pos - Enum WatermarkPosition which represents the position of the Watermark for centre, fit to image position or to the specified co-ords
      alphaComposite - AlphaComposite to be used when applying watermark
      properties - Enum WatermarkShapeProperties to use when applying the watermark
      Returns:
      The instance of ImageProcessingOperations that includes the watermark operation.
    • undo

      Removes the most recently added operation. Up to 5 undone operations are kept so they can be restored with redo(). Does nothing if there are no operations.
      Returns:
      This instance of ImageProcessingOperations.
    • redo

      Adds back the operation most recently removed by undo(). Does nothing if there is nothing to redo.
      Returns:
      This instance of ImageProcessingOperations.
    • operationsListSize

      public int operationsListSize()
      Returns the number of operations that will be applied.
      Returns:
      number of operations in the list