Class JDeli

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.JDeli

public class JDeli extends com.idrsolutions.image.JDeliImage
Class reads, writes and processes images.

Example to read an image, where:

  • imageFile is of type File

 JDeli.read(imageFile);
 

Example to write an image, where:

  • image is of type BufferedImage
  • outputFormat is of type OutputFormat
  • outputFile is of type File

 JDeli.write(image, OutputFormat.PNG, outputFile);
 or
 JDeli.write(image, "png", outputFile);
 or
 JDeli.write(image, "png", outputStream);

 
  • Constructor Details

    • JDeli

      public JDeli()
  • Method Details

    • convert

      public static void convert(File inputFile, File outputFile) throws Exception
      Convert between any supported image file formats
      Parameters:
      inputFile - source file
      outputFile - destination for output
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static void convert(File inputFile, EncoderOptions outputOptions, File outputFile) throws Exception
      Convert between any supported image file formats
      Parameters:
      inputFile - source file
      outputOptions - set values to control output
      outputFile - destination for output
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static void convert(InputStream inputStream, EncoderOptions outputOptions, OutputStream outputStream, String format) throws Exception
      Convert between any supported image file formats
      Parameters:
      inputStream - source inputStream
      outputOptions - set values to control output
      outputStream - destination for output
      format - image format
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static void convert(File inputFile, File outputFile, ImageProcessingOps operations) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputFile - source file
      outputFile - destination for output
      operations - image processing operations to perform
      Throws:
      Exception - if an error occurs in converting image
    • process

      public static BufferedImage process(ImageProcessingOps operations, BufferedImage image)
      Returns BufferedImage with processing options applied
      Parameters:
      operations - Image processing operations to apply
      image - source image for processing
      Returns:
      BufferedImage
    • convert

      public static void convert(InputStream inputStream, OutputStream outputStream, String format) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputStream - source InputStream
      outputStream - destination OutpytStream
      format - image filetype (ie PNG)
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static void convert(InputStream inputStream, OutputStream outputStream, String format, ImageProcessingOps operations) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputStream - source InputStream
      outputStream - destination OutputStream
      format - image filetype (ie PNG)
      operations - image processing operations to perform
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static byte[] convert(byte[] inputData, String format) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputData - byte[] containing image data
      format - image filetype (ie PNG)
      Returns:
      byte[] object containing output image data
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static byte[] convert(byte[] inputData, String format, ImageProcessingOps operations) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputData - byte[] containing image data
      format - image filetype (ie PNG)
      operations - image processing operations to perform
      Returns:
      byte[] object containing output image data
      Throws:
      Exception - if an error occurs in converting image
    • convert

      public static byte[] convert(byte[] inputData, EncoderOptions options) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputData - byte[] containing image data
      options - options to use when encoding
      Returns:
      byte[] object containing output image data
      Throws:
      Exception - if an error occurs in converting image
    • getImageInfo

      public static Metadata getImageInfo(File imageFile) throws Exception
      Returns Metadata object describing Image
      Parameters:
      imageFile - source image path
      Returns:
      Specific instance of Metadata (ie BMPMetadata)
      Throws:
      Exception - if an error occurs in reading image
    • getImageInfo

      public static Metadata getImageInfo(byte[] imageBytes) throws Exception
      Returns Metadata object describing Image
      Parameters:
      imageBytes - source image data
      Returns:
      Specific instance of Metadata (ie BMPMetadata)
      Throws:
      Exception - if an error occurs in reading image
    • getImageInfo

      public static Metadata getImageInfo(InputStream inputStream) throws Exception
      Returns Metadata object describing Image
      Parameters:
      inputStream - source for image data
      Returns:
      Specific instance of Metadata (ie BMPMetadata)
      Throws:
      Exception - if an error occurs in reading image
    • readEmbeddedThumbnail

      public static BufferedImage readEmbeddedThumbnail(byte[] imageBytes) throws Exception
      Returns an embedded Thumbnail if found in Image file (or null)
      Parameters:
      imageBytes - source image data
      Returns:
      BufferedImage or null if no embedded thumbnail present
      Throws:
      Exception - if an error occurs in reading image
    • readEmbeddedThumbnail

      public static BufferedImage readEmbeddedThumbnail(File imageFile) throws Exception
      Returns an embedded Thumbnail if found in Image file (or null)
      Parameters:
      imageFile - source image path
      Returns:
      BufferedImage or null if no embedded thumbnail present
      Throws:
      Exception - if an error occurs in reading image
    • readEmbeddedThumbnail

      public static BufferedImage readEmbeddedThumbnail(InputStream inputStream) throws Exception
      Returns an embedded Thumbnail if found in Image file (or null)
      Parameters:
      inputStream - source image path
      Returns:
      BufferedImage or null if no embedded thumbnail present
      Throws:
      Exception - if an error occurs in reading image
    • readDimension

      public static Rectangle readDimension(byte[] imageBytes) throws Exception
      Returns an Image dimensions
      Parameters:
      imageBytes - source image data
      Returns:
      Rectangle or null if not supported or unable to read
      Throws:
      Exception - if an error occurs in reading image
    • readDimension

      public static Rectangle readDimension(File imageFile) throws Exception
      Returns an Image dimensions
      Parameters:
      imageFile - source image path
      Returns:
      Rectangle or null if not supported or unable to read
      Throws:
      Exception - if an error occurs in reading image
    • readDimension

      public static Rectangle readDimension(InputStream inputStream) throws Exception
      Returns an Image dimensions
      Parameters:
      inputStream - source image path
      Returns:
      Rectangle or null if not supported or unable to read
      Throws:
      Exception - if an error occurs in reading image
    • read

      public static BufferedImage read(File imageFile) throws Exception
      Returns BufferedImage from the File object if supported ImageType
      Parameters:
      imageFile - path for image file
      Returns:
      BufferedImage
      Throws:
      Exception - if an error occurs in reading image
    • read

      public static BufferedImage read(File imageFile, HashMap<String,String> map) throws Exception
      Returns BufferedImage from the File object if supported ImageType
      Parameters:
      imageFile - path for image file
      map - map to put custom parameters
      Returns:
      BufferedImage
      Throws:
      Exception - if an error occurs in reading image
    • read

      public static BufferedImage read(byte[] data, HashMap<String,String> map) throws Exception
      Returns BufferedImage from the byte[] if supported ImageType
      Parameters:
      data - compressed image data as bytes
      map - map to put custom parameters
      Returns:
      BufferedImage
      Throws:
      Exception - if an error occurs in reading image
    • read

      public static BufferedImage read(byte[] data) throws Exception
      Returns BufferedImage from InputStream if supported ImageType bytes
      Parameters:
      data - raw image bytes
      Returns:
      BufferedImage
      Throws:
      Exception - if an error occurs in reading image
    • read

      public static BufferedImage read(InputStream is, HashMap<String,String> map) throws Exception
      Returns BufferedImage from InputStream if supported ImageType
      Parameters:
      is - input stream to read from
      map - configuration options to apply
      Returns:
      BufferedImage
      Throws:
      Exception - if an error occurs in reading image
      See Also:
      Implementation Note:
      If you are passing in a ByteArrayInputStream it may be more effective to use our read(byte[], HashMap) method instead
    • read

      public static BufferedImage read(InputStream is) throws Exception
      Returns BufferedImage from InputStream if supported ImageType stream
      Parameters:
      is - input stream to read from
      Returns:
      BufferedImage
      Throws:
      Exception - if an error occurs in reading image
      See Also:
      Implementation Note:
      If you are passing in a ByteArrayInputStream it may be more effective to use our read(byte[]) method instead
    • write

      public static void write(BufferedImage image, EncoderOptions options, File outputFile) throws Exception
      This method compress the buffered image into given output format
      Parameters:
      image - bufferedImage
      options - WriterOptions
      outputFile - output file
      Throws:
      Exception - if an error occurs in reading image
      See Also:
    • write

      public static byte[] write(BufferedImage image, EncoderOptions options) throws Exception
      This method compress the buffered image into given output format
      Parameters:
      image - bufferedImage
      options - WriterOptions
      Returns:
      byte[] the data array written out or an empty array if no encoder is found
      Throws:
      Exception - if an error occurs in reading image
      See Also:
    • write

      public static void write(BufferedImage image, OutputFormat format, File outputFile) throws Exception
      This method compress the buffered image into given output format
      Parameters:
      image - bufferedImage
      format - output format
      outputFile - output file
      Throws:
      Exception - if an error occurs in reading image
      See Also:
    • write

      public static void write(BufferedImage image, String formatName, File outputFile) throws Exception
      This method writes out a BufferedImage to any supported ImageType
      Parameters:
      image - bufferedImage
      formatName - output format name
      outputFile - output file
      Throws:
      Exception - if an error occurs in writing image
      See Also:
    • filter

      public static byte[] filter(byte[] raw_data, FilterOptions options) throws Exception
      This method filters the data using the chosen algorithm
      Parameters:
      raw_data - byte[]
      options - FilterOptions
      Returns:
      byte[] the data array written out
      Throws:
      Exception - if an error occurs in filter operation
    • filter

      public static void filter(InputStream inputStream, FilterOptions options, OutputStream outputStream) throws Exception
      This method filters the data using the chosen algorithm
      Parameters:
      inputStream - InputStream
      options - FilterOptions
      outputStream - OutputStream
      Throws:
      Exception - if an error occurs in filter operation
      See Also:
    • isImageSupportedForOutput

      public static boolean isImageSupportedForOutput(String formatName)
      return whether the image format name is supported for writing
      Parameters:
      formatName - three letter file format
      Returns:
      value to show if image can be output by jdeli
    • isImageSupportedForInput

      public static boolean isImageSupportedForInput(String formatName)
      return whether the image format name is supported for reading from
      Parameters:
      formatName - three letter file format
      Returns:
      value to show if image can be read by jdeli
    • write

      public static byte[] write(BufferedImage image, String formatName) throws Exception
      This method writes out a BufferedImage to any supported ImageType to a byte[] array
      Parameters:
      image - bufferedImage
      formatName - output format name
      Returns:
      byte[] with output image as bytes
      Throws:
      Exception - if an error occurs in writing image
    • write

      public static void write(BufferedImage image, String formatName, OutputStream stream) throws Exception
      This method writes out a BufferedImage to any supported ImageType

      This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.

      Parameters:
      image - bufferedImage
      formatName - output format name
      stream - output stream
      Throws:
      Exception - if an error occurs in writing image
    • write

      public static void write(BufferedImage image, EncoderOptions options, OutputStream outputStream) throws Exception
      This method compress the buffered image into given output format

      This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.

      Parameters:
      image - bufferedImage
      options - WriterOptions
      outputStream - outputStream
      Throws:
      Exception - if an error occurs in writing image
      See Also:
    • write

      public static void write(BufferedImage image, OutputFormat format, OutputStream outputStream) throws Exception
      This method compress the buffered image into given output format

      This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.

      Parameters:
      image - bufferedImage
      format - output format
      outputStream - outputStream
      Throws:
      Exception - if an error occurs in writing image
      See Also: