Class JDeli

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

public class JDeli extends com.idrsolutions.image.JDeliImage
Class reads and writes image files.

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);

 
  • Field Summary

    Fields inherited from class com.idrsolutions.image.JDeliImage

    bb
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    convert(byte[] inputData, com.idrsolutions.image.encoder.options.EncoderOptions options)
    Convert between any supported image file formats and process image
    static byte[]
    convert(byte[] inputData, String format)
    Convert between any supported image file formats and process image
    static byte[]
    convert(byte[] inputData, String format, com.idrsolutions.image.process.ImageProcessingOps operations)
    Convert between any supported image file formats and process image
    static void
    convert(File inputFile, com.idrsolutions.image.encoder.options.EncoderOptions outputOptions, File outputFile)
    Convert between any supported image file formats
    static void
    convert(File inputFile, File outputFile)
    Convert between any supported image file formats
    static void
    convert(File inputFile, File outputFile, com.idrsolutions.image.process.ImageProcessingOps operations)
    Convert between any supported image file formats and process image
    static void
    convert(InputStream inputStream, com.idrsolutions.image.encoder.options.EncoderOptions outputOptions, OutputStream outputStream, String format)
    Convert between any supported image file formats
    static void
    convert(InputStream inputStream, OutputStream outputStream, String format)
    Convert between any supported image file formats and process image
    static void
    convert(InputStream inputStream, OutputStream outputStream, String format, com.idrsolutions.image.process.ImageProcessingOps operations)
    Convert between any supported image file formats and process image
    static byte[]
    filter(byte[] raw_data, com.idrsolutions.image.filter.FilterOptions options)
    This method filters the data using the chosen algorithm
    static void
    filter(InputStream inputStream, com.idrsolutions.image.filter.FilterOptions options, OutputStream outputStream)
    This method filters the data using the chosen algorithm
    static com.idrsolutions.image.metadata.Metadata
    getImageInfo(byte[] imageBytes)
    Returns Metadata object describing Image
    static com.idrsolutions.image.metadata.Metadata
    getImageInfo(File imageFile)
    Returns Metadata object describing Image
    static com.idrsolutions.image.metadata.Metadata
    Returns Metadata object describing Image
    static boolean
    return whether the image format name is supported for reading from
    static boolean
    return whether the image format name is supported for writing
    process(com.idrsolutions.image.process.ImageProcessingOps operations, BufferedImage image)
    Returns BufferedImage with processing options applied
    read(byte[] data)
    Returns BufferedImage from InputStream if supported ImageType bytes
    read(byte[] data, HashMap<String,String> map)
    Returns BufferedImage from the byte[] if supported ImageType
    read(File imageFile)
    Returns BufferedImage from the File object if supported ImageType
    read(File imageFile, HashMap<String,String> map)
    Returns BufferedImage from the File object if supported ImageType
    Returns BufferedImage from InputStream if supported ImageType stream
    Returns BufferedImage from InputStream if supported ImageType
    static Rectangle
    readDimension(byte[] imageBytes)
    Returns an Image dimensions
    static Rectangle
    readDimension(File imageFile)
    Returns an Image dimensions
    static Rectangle
    Returns an Image dimensions
    readEmbeddedThumbnail(byte[] imageBytes)
    Returns an embedded Thumbnail if found in Image file (or null)
    Returns an embedded Thumbnail if found in Image file (or null)
    Returns an embedded Thumbnail if found in Image file (or null)
    static byte[]
    write(BufferedImage image, com.idrsolutions.image.encoder.options.EncoderOptions options)
    This method compress the buffered image into given output format
    static void
    write(BufferedImage image, com.idrsolutions.image.encoder.options.EncoderOptions options, File outputFile)
    This method compress the buffered image into given output format
    static void
    write(BufferedImage image, com.idrsolutions.image.encoder.options.EncoderOptions options, OutputStream outputStream)
    This method compress the buffered image into given output format
    static void
    write(BufferedImage image, com.idrsolutions.image.encoder.OutputFormat format, File outputFile)
    This method compress the buffered image into given output format
    static void
    write(BufferedImage image, com.idrsolutions.image.encoder.OutputFormat format, OutputStream outputStream)
    This method compress the buffered image into given output format
    static byte[]
    write(BufferedImage image, String formatName)

    This method writes out a BufferedImage to any supported ImageType to a byte[] array
    static void
    write(BufferedImage image, String formatName, File outputFile)
    This method writes out a BufferedImage to any supported ImageType
    static void
    write(BufferedImage image, String formatName, OutputStream stream)
    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.

    Methods inherited from class com.idrsolutions.image.JDeliImage

    optimiseImage

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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, com.idrsolutions.image.encoder.options.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, com.idrsolutions.image.encoder.options.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, com.idrsolutions.image.process.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(com.idrsolutions.image.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, com.idrsolutions.image.process.ImageProcessingOps operations) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputStream - source InputStream
      outputStream - destination OutputStream
      operations - image processing operations to perform
      format - image filetype (ie PNG)
      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, com.idrsolutions.image.process.ImageProcessingOps operations) throws Exception
      Convert between any supported image file formats and process image
      Parameters:
      inputData - byte[] containing image data
      operations - image processing operations to perform
      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, com.idrsolutions.image.encoder.options.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 com.idrsolutions.image.metadata.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 com.idrsolutions.image.metadata.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 com.idrsolutions.image.metadata.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, com.idrsolutions.image.encoder.options.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:
      • OutputFormat
    • write

      public static byte[] write(BufferedImage image, com.idrsolutions.image.encoder.options.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:
      • OutputFormat
    • write

      public static void write(BufferedImage image, com.idrsolutions.image.encoder.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:
      • OutputFormat
    • 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:
      • OutputFormat
    • filter

      public static byte[] filter(byte[] raw_data, com.idrsolutions.image.filter.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, com.idrsolutions.image.filter.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:
      • OutputFormat
    • 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, com.idrsolutions.image.encoder.options.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:
      • OutputFormat
    • write

      public static void write(BufferedImage image, com.idrsolutions.image.encoder.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:
      • OutputFormat