Class ImageParser


  • public abstract class ImageParser
    extends org.apache.commons.imaging.common.BinaryFileParser
    Provides the abstract base class for all image reading and writing utilities. ImageParser implementations are expected to extend this class providing logic for identifying and processing data in their own specific format. Specific implementations are found under the com.apache.commons.imaging.formats package.

    Application Notes

    Format support

    For the most recent information on format support for the Apache Commons Imaging package, refer to Format Support at the main project development web site.

    On the accuracy of this Javadoc

    The original authors of this class did not supply documentation. The Javadoc for this class is based on inspection of the source code. In some cases, the purpose and usage for particular methods was deduced from the source and may not perfectly reflect the intentions of the original. Therefore, you should not assume that the documentation is perfect, especially in the more obscure and specialized areas of implementation.

    The "Map params" argument

    Many of the methods specified by this class accept an argument of type Map giving a list of parameters to be used when processing an image. For example, some of the output formats permit the specification of different kinds of image compression or color models. Some of the reading methods permit the calling application to require strict format compliance. In many cases, however, an application will not require the use of this argument. While some of the ImageParser implementations check for (and ignore) null arguments for this parameter, not all of them do (at least not at the time these notes were written). Therefore, a prudent programmer will always supply an valid, though empty instance of a Map implementation when calling such methods. Generally, the java HashMap class is useful for this purpose.

    Additionally, developers creating or enhancing classes derived from ImageParser are encouraged to include such checks in their code.

    • Constructor Summary

      Constructors 
      Constructor Description
      ImageParser()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canAcceptType​(ImageFormat type)
      Indicates whether the ImageParser implementation can accept the specified format
      java.lang.String dumpImageFile​(byte[] bytes)
      Write the ImageInfo and format-specific information for the image content of the specified byte array to a string.
      java.lang.String dumpImageFile​(java.io.File file)
      Write the ImageInfo and format-specific information for the image content of the specified file to a string.
      boolean dumpImageFile​(java.io.PrintWriter pw, ByteSource byteSource)
      Write the ImageInfo and format-specific information for the image content of the specified byte source to a PrintWriter
      java.lang.String dumpImageFile​(ByteSource byteSource)
      Write the ImageInfo and format-specific information for the image content of the specified byte source to a string.
      java.util.List<java.awt.image.BufferedImage> getAllBufferedImages​(byte[] bytes)
      Gets all images specified by the byte array (some formats may include multiple images within a single data source).
      java.util.List<java.awt.image.BufferedImage> getAllBufferedImages​(java.io.File file)
      Gets all images specified by indicated file (some formats may include multiple images within a single data source).
      java.util.List<java.awt.image.BufferedImage> getAllBufferedImages​(ByteSource byteSource)
      Gets all images specified by the byte source (some formats may include multiple images within a single data source).
      static ImageParser[] getAllImageParsers()
      Gets an array of new instances of all image parsers.
      java.awt.image.BufferedImage getBufferedImage​(byte[] bytes, java.util.Map<java.lang.String,​java.lang.Object> params)
      Gets a buffered image specified by the byte array (for sources that specify multiple images, choice of which image is returned is implementation dependent).
      java.awt.image.BufferedImage getBufferedImage​(java.io.File file, java.util.Map<java.lang.String,​java.lang.Object> params)
      Gets a buffered image specified by the indicated file (for sources that specify multiple images, choice of which image is returned is implementation dependent).
      abstract java.awt.image.BufferedImage getBufferedImage​(ByteSource byteSource, java.util.Map<java.lang.String,​java.lang.Object> params)
      Gets a buffered image specified by the byte source (for sources that specify multiple images, choice of which image is returned is implementation dependent).
      abstract java.lang.String getDefaultExtension()
      Get the default extension for the format specified by an implementation of ImageParser.
      FormatCompliance getFormatCompliance​(byte[] bytes)
      Determines the format compliance of the content of the supplied byte array based on rules provided by a specific implementation.
      FormatCompliance getFormatCompliance​(java.io.File file)
      Determines the format compliance of the specified file based on rules provided by a specific implementation.
      FormatCompliance getFormatCompliance​(ByteSource byteSource)
      Determines the format compliance of the content of the supplied byte source based on rules provided by a specific implementation.
      byte[] getICCProfileBytes​(byte[] bytes)
      Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input byte array.
      byte[] getICCProfileBytes​(byte[] bytes, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input byte array.
      byte[] getICCProfileBytes​(java.io.File file)
      Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input file.
      byte[] getICCProfileBytes​(java.io.File file, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input file.
      abstract byte[] getICCProfileBytes​(ByteSource byteSource, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input byteSoruce.
      ImageInfo getImageInfo​(byte[] bytes, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get image information from the specified array of bytes.
      ImageInfo getImageInfo​(java.io.File file, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get image information from the specified file Format-specific ImageParser implementations are expected to return a valid ImageInfo object or to throw an ImageReadException if unable to process the specified data.
      ImageInfo getImageInfo​(ByteSource byteSource)
      Get image information from the specified ByteSource.
      abstract ImageInfo getImageInfo​(ByteSource byteSource, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get image information from the specified ByteSource.
      java.awt.Dimension getImageSize​(byte[] bytes)
      Get the size of the image described by the specified byte array.
      java.awt.Dimension getImageSize​(byte[] bytes, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get the size of the image described by the specified byte array.
      java.awt.Dimension getImageSize​(java.io.File file)
      Get the size of the image described by the specified file.
      java.awt.Dimension getImageSize​(java.io.File file, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get the size of the image described by the specified file.
      abstract java.awt.Dimension getImageSize​(ByteSource byteSource, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get the size of the image described by the specified ByteSource.
      org.apache.commons.imaging.common.ImageMetadata getMetadata​(byte[] bytes)
      Get image metadata from the specified array of bytes.
      org.apache.commons.imaging.common.ImageMetadata getMetadata​(byte[] bytes, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get image metadata from the specified array of bytes.
      org.apache.commons.imaging.common.ImageMetadata getMetadata​(java.io.File file)
      Get image metadata from the specified file.
      org.apache.commons.imaging.common.ImageMetadata getMetadata​(java.io.File file, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get image metadata from the specified file.
      org.apache.commons.imaging.common.ImageMetadata getMetadata​(ByteSource byteSource)
      Get image metadata from the specified byte source.
      abstract org.apache.commons.imaging.common.ImageMetadata getMetadata​(ByteSource byteSource, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get image metadata from the specified byte source.
      abstract java.lang.String getName()
      Get a descriptive name for the implementation of an ImageParser.
      abstract java.lang.String getXmpXml​(ByteSource byteSource, java.util.Map<java.lang.String,​java.lang.Object> params)
      Get a string containing XML-formatted text conforming to the Extensible Metadata Platform (EXP) standard for representing information about image content.
      static boolean isStrict​(java.util.Map<java.lang.String,​java.lang.Object> params)
      A utility method to search a params specification and determine whether it contains the ImagingConstants.PARAM_KEY_STRICT specification.
      void writeImage​(java.awt.image.BufferedImage src, java.io.OutputStream os, java.util.Map<java.lang.String,​java.lang.Object> params)
      Writes the content of a BufferedImage to the specified output stream.
      • Methods inherited from class org.apache.commons.imaging.common.BinaryFileParser

        getByteOrder, getDebug, setDebug
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageParser

        public ImageParser()
    • Method Detail

      • getAllImageParsers

        public static ImageParser[] getAllImageParsers()
        Gets an array of new instances of all image parsers.
        Returns:
        A valid array of image parsers
      • getMetadata

        public final org.apache.commons.imaging.common.ImageMetadata getMetadata​(ByteSource byteSource)
                                                                          throws ImageReadException,
                                                                                 java.io.IOException
        Get image metadata from the specified byte source. Format-specific ImageParser implementations are expected to return a valid IImageMetadata object or to throw an ImageReadException if unable to process the specified byte source.
        Parameters:
        byteSource - A valid byte source.
        Returns:
        A valid, potentially subject-matter-specific implementation of the IImageMetadata interface describing the content extracted from the source content.
        Throws:
        ImageReadException - In the event that the the ByteSource content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data read operation.
      • getMetadata

        public abstract org.apache.commons.imaging.common.ImageMetadata getMetadata​(ByteSource byteSource,
                                                                                    java.util.Map<java.lang.String,​java.lang.Object> params)
                                                                             throws ImageReadException,
                                                                                    java.io.IOException
        Get image metadata from the specified byte source. Format-specific ImageParser implementations are expected to return a valid IImageMetadata object or to throw an ImageReadException if unable to process the specified byte source.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will require this capability. Because the base class may call this method with a null params argument, implementations should always include logic for ignoring null input.

        Parameters:
        byteSource - A valid byte source.
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid, potentially subject-matter-specific implementation of the IImageMetadata interface describing the content extracted from the source content.
        Throws:
        ImageReadException - In the event that the the ByteSource content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data read operation.
      • getMetadata

        public final org.apache.commons.imaging.common.ImageMetadata getMetadata​(byte[] bytes)
                                                                          throws ImageReadException,
                                                                                 java.io.IOException
        Get image metadata from the specified array of bytes. Format-specific ImageParser implementations are expected to return a valid IImageMetadata object or to throw an ImageReadException if unable to process the specified data.
        Parameters:
        bytes - A valid array of bytes
        Returns:
        A valid, potentially subject-matter-specific implementation of the IImageMetadata interface describing the content extracted from the source content.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data read operation.
      • getMetadata

        public final org.apache.commons.imaging.common.ImageMetadata getMetadata​(byte[] bytes,
                                                                                 java.util.Map<java.lang.String,​java.lang.Object> params)
                                                                          throws ImageReadException,
                                                                                 java.io.IOException
        Get image metadata from the specified array of bytes. Format-specific ImageParser implementations are expected to return a valid IImageMetadata object or to throw an ImageReadException if unable to process the specified data.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will require this capability. Because the base class may call this method with a null params argument, implementations should always include logic for ignoring null input.

        Parameters:
        bytes - A valid array of bytes
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid image metadata object describing the content extracted from the specified content.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data read operation.
      • getMetadata

        public final org.apache.commons.imaging.common.ImageMetadata getMetadata​(java.io.File file)
                                                                          throws ImageReadException,
                                                                                 java.io.IOException
        Get image metadata from the specified file. Format-specific ImageParser implementations are expected to return a valid IImageMetadata object or to throw an ImageReadException if unable to process the specified data.
        Parameters:
        file - A valid reference to a file.
        Returns:
        A valid image metadata object describing the content extracted from the specified content.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful file read or access operation.
      • getMetadata

        public final org.apache.commons.imaging.common.ImageMetadata getMetadata​(java.io.File file,
                                                                                 java.util.Map<java.lang.String,​java.lang.Object> params)
                                                                          throws ImageReadException,
                                                                                 java.io.IOException
        Get image metadata from the specified file. Format-specific ImageParser implementations are expected to return a valid IImageMetadata object or to throw an ImageReadException if unable to process the specified data.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will require this capability. Because the base class may call this method with a null params argument, implementations should always include logic for ignoring null input.

        Parameters:
        file - A valid reference to a file.
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid image metadata object describing the content extracted from the specified content.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful file read or access operation.
      • getImageInfo

        public abstract ImageInfo getImageInfo​(ByteSource byteSource,
                                               java.util.Map<java.lang.String,​java.lang.Object> params)
                                        throws ImageReadException,
                                               java.io.IOException
        Get image information from the specified ByteSource. Format-specific ImageParser implementations are expected to return a valid ImageInfo object or to throw an ImageReadException if unable to process the specified data.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will require this capability. Because the base class may call this method with a null params argument, implementations should always include logic for ignoring null input.

        Parameters:
        byteSource - A valid ByteSource object
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid image information object describing the content extracted from the specified data.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data access operation.
      • getImageInfo

        public final ImageInfo getImageInfo​(ByteSource byteSource)
                                     throws ImageReadException,
                                            java.io.IOException
        Get image information from the specified ByteSource. Format-specific ImageParser implementations are expected to return a valid ImageInfo object or to throw an ImageReadException if unable to process the specified data.
        Parameters:
        byteSource - A valid ByteSource object
        Returns:
        A valid image information object describing the content extracted from the specified data.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data access operation.
      • getImageInfo

        public final ImageInfo getImageInfo​(byte[] bytes,
                                            java.util.Map<java.lang.String,​java.lang.Object> params)
                                     throws ImageReadException,
                                            java.io.IOException
        Get image information from the specified array of bytes. Format-specific ImageParser implementations are expected to return a valid ImageInfo object or to throw an ImageReadException if unable to process the specified data.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will require this capability. Because the base class may call this method with a null params argument, implementations should always include logic for ignoring null input.

        Parameters:
        bytes - A valid array of bytes
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid image information object describing the content extracted from the specified data.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful data access operation.
      • getImageInfo

        public final ImageInfo getImageInfo​(java.io.File file,
                                            java.util.Map<java.lang.String,​java.lang.Object> params)
                                     throws ImageReadException,
                                            java.io.IOException
        Get image information from the specified file Format-specific ImageParser implementations are expected to return a valid ImageInfo object or to throw an ImageReadException if unable to process the specified data.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will require this capability. Because the base class may call this method with a null params argument, implementations should always include logic for ignoring null input.

        Parameters:
        file - A valid File object
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid image information object describing the content extracted from the specified data.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful file read or access operation.
      • getFormatCompliance

        public FormatCompliance getFormatCompliance​(ByteSource byteSource)
                                             throws ImageReadException,
                                                    java.io.IOException
        Determines the format compliance of the content of the supplied byte source based on rules provided by a specific implementation.
        Parameters:
        byteSource - A valid instance of ByteSource
        Returns:
        true if the content is format-compliant; otherwise, false
        Throws:
        ImageReadException - may be thrown by sub-classes
        java.io.IOException - may be thrown by sub-classes
      • getFormatCompliance

        public final FormatCompliance getFormatCompliance​(byte[] bytes)
                                                   throws ImageReadException,
                                                          java.io.IOException
        Determines the format compliance of the content of the supplied byte array based on rules provided by a specific implementation.
        Parameters:
        bytes - A valid byte array.
        Returns:
        A valid FormatCompliance object.
        Throws:
        ImageReadException - may be thrown by sub-classes
        java.io.IOException - may be thrown by sub-classes
      • getFormatCompliance

        public final FormatCompliance getFormatCompliance​(java.io.File file)
                                                   throws ImageReadException,
                                                          java.io.IOException
        Determines the format compliance of the specified file based on rules provided by a specific implementation.
        Parameters:
        file - A valid reference to a file.
        Returns:
        A valid format compliance object.
        Throws:
        ImageReadException - may be thrown by sub-classes
        java.io.IOException - may be thrown by sub-classes
      • getAllBufferedImages

        public java.util.List<java.awt.image.BufferedImage> getAllBufferedImages​(ByteSource byteSource)
                                                                          throws ImageReadException,
                                                                                 java.io.IOException
        Gets all images specified by the byte source (some formats may include multiple images within a single data source).
        Parameters:
        byteSource - A valid instance of ByteSource.
        Returns:
        A valid (potentially empty) list of BufferedImage objects.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getAllBufferedImages

        public final java.util.List<java.awt.image.BufferedImage> getAllBufferedImages​(byte[] bytes)
                                                                                throws ImageReadException,
                                                                                       java.io.IOException
        Gets all images specified by the byte array (some formats may include multiple images within a single data source).
        Parameters:
        bytes - A valid byte array
        Returns:
        A valid (potentially empty) list of BufferedImage objects.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getAllBufferedImages

        public final java.util.List<java.awt.image.BufferedImage> getAllBufferedImages​(java.io.File file)
                                                                                throws ImageReadException,
                                                                                       java.io.IOException
        Gets all images specified by indicated file (some formats may include multiple images within a single data source).
        Parameters:
        file - A valid reference to a file.
        Returns:
        A valid (potentially empty) list of BufferedImage objects.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getBufferedImage

        public abstract java.awt.image.BufferedImage getBufferedImage​(ByteSource byteSource,
                                                                      java.util.Map<java.lang.String,​java.lang.Object> params)
                                                               throws ImageReadException,
                                                                      java.io.IOException
        Gets a buffered image specified by the byte source (for sources that specify multiple images, choice of which image is returned is implementation dependent).
        Parameters:
        byteSource - A valid instance of ByteSource
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid instance of BufferedImage.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getBufferedImage

        public final java.awt.image.BufferedImage getBufferedImage​(byte[] bytes,
                                                                   java.util.Map<java.lang.String,​java.lang.Object> params)
                                                            throws ImageReadException,
                                                                   java.io.IOException
        Gets a buffered image specified by the byte array (for sources that specify multiple images, choice of which image is returned is implementation dependent).
        Parameters:
        bytes - A valid byte array
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid instance of BufferedImage.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getBufferedImage

        public final java.awt.image.BufferedImage getBufferedImage​(java.io.File file,
                                                                   java.util.Map<java.lang.String,​java.lang.Object> params)
                                                            throws ImageReadException,
                                                                   java.io.IOException
        Gets a buffered image specified by the indicated file (for sources that specify multiple images, choice of which image is returned is implementation dependent).
        Parameters:
        file - A valid file reference.
        params - Optional instructions for special-handling or interpretation of the input data (null objects are permitted and must be supported by implementations).
        Returns:
        A valid instance of BufferedImage.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • writeImage

        public void writeImage​(java.awt.image.BufferedImage src,
                               java.io.OutputStream os,
                               java.util.Map<java.lang.String,​java.lang.Object> params)
                        throws ImageWriteException,
                               java.io.IOException
        Writes the content of a BufferedImage to the specified output stream.

        The params argument provides a mechanism for individual implementations to pass optional information into the parser. Not all formats will support this capability. Currently, some of the parsers do not check for null arguments. So in cases where no optional specifications are supported, application code should pass in an empty instance of an implementation of the map interface (i.e. an empty HashMap).

        Parameters:
        src - An image giving the source content for output
        os - A valid output stream for storing the formatted image
        params - A non-null Map implementation supplying optional, format-specific instructions for output (such as selections for data compression, color models, etc.)
        Throws:
        ImageWriteException - In the event that the output format cannot handle the input image or invalid params are specified.
        java.io.IOException - In the event of an write error from the output stream.
      • getImageSize

        public final java.awt.Dimension getImageSize​(byte[] bytes)
                                              throws ImageReadException,
                                                     java.io.IOException
        Get the size of the image described by the specified byte array.
        Parameters:
        bytes - A valid byte array.
        Returns:
        A valid instance of Dimension.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getImageSize

        public final java.awt.Dimension getImageSize​(byte[] bytes,
                                                     java.util.Map<java.lang.String,​java.lang.Object> params)
                                              throws ImageReadException,
                                                     java.io.IOException
        Get the size of the image described by the specified byte array.
        Parameters:
        bytes - A valid byte array.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        A valid instance of Dimension.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getImageSize

        public final java.awt.Dimension getImageSize​(java.io.File file)
                                              throws ImageReadException,
                                                     java.io.IOException
        Get the size of the image described by the specified file.
        Parameters:
        file - A valid reference to a file.
        Returns:
        A valid instance of Dimension.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getImageSize

        public final java.awt.Dimension getImageSize​(java.io.File file,
                                                     java.util.Map<java.lang.String,​java.lang.Object> params)
                                              throws ImageReadException,
                                                     java.io.IOException
        Get the size of the image described by the specified file.
        Parameters:
        file - A valid reference to a file.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        A valid instance of Dimension.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getImageSize

        public abstract java.awt.Dimension getImageSize​(ByteSource byteSource,
                                                        java.util.Map<java.lang.String,​java.lang.Object> params)
                                                 throws ImageReadException,
                                                        java.io.IOException
        Get the size of the image described by the specified ByteSource.
        Parameters:
        byteSource - A valid reference to a ByteSource.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        A valid instance of Dimension.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getXmpXml

        public abstract java.lang.String getXmpXml​(ByteSource byteSource,
                                                   java.util.Map<java.lang.String,​java.lang.Object> params)
                                            throws ImageReadException,
                                                   java.io.IOException
        Get a string containing XML-formatted text conforming to the Extensible Metadata Platform (EXP) standard for representing information about image content. Not all image formats support EXP infomation and even for those that do, there is no guarantee that such information will be present in an image.
        Parameters:
        byteSource - A valid reference to a ByteSource.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        If XMP metadata is present, a valid string; if it is not present, a null.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getICCProfileBytes

        public final byte[] getICCProfileBytes​(byte[] bytes)
                                        throws ImageReadException,
                                               java.io.IOException
        Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input byte array. Not all formats support ICC profiles.
        Parameters:
        bytes - A valid array of bytes.
        Returns:
        If available, a valid array of bytes; otherwise, a null
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getICCProfileBytes

        public final byte[] getICCProfileBytes​(byte[] bytes,
                                               java.util.Map<java.lang.String,​java.lang.Object> params)
                                        throws ImageReadException,
                                               java.io.IOException
        Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input byte array. Not all formats support ICC profiles.
        Parameters:
        bytes - A valid array of bytes.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        If available, a valid array of bytes; otherwise, a null
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getICCProfileBytes

        public final byte[] getICCProfileBytes​(java.io.File file)
                                        throws ImageReadException,
                                               java.io.IOException
        Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input file. Not all formats support ICC profiles.
        Parameters:
        file - A valid file reference.
        Returns:
        If available, a valid array of bytes; otherwise, a null
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getICCProfileBytes

        public final byte[] getICCProfileBytes​(java.io.File file,
                                               java.util.Map<java.lang.String,​java.lang.Object> params)
                                        throws ImageReadException,
                                               java.io.IOException
        Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input file. Not all formats support ICC profiles.
        Parameters:
        file - A valid file reference.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        If available, a valid array of bytes; otherwise, a null
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getICCProfileBytes

        public abstract byte[] getICCProfileBytes​(ByteSource byteSource,
                                                  java.util.Map<java.lang.String,​java.lang.Object> params)
                                           throws ImageReadException,
                                                  java.io.IOException
        Get an array of bytes describing the International Color Consortium (ICC) specification for the color space of the image contained in the input byteSoruce. Not all formats support ICC profiles.
        Parameters:
        byteSource - A valid ByteSource.
        params - Optional instructions for special-handling or interpretation of the input data.
        Returns:
        If available, a valid array of bytes; otherwise, a null
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • dumpImageFile

        public final java.lang.String dumpImageFile​(byte[] bytes)
                                             throws ImageReadException,
                                                    java.io.IOException
        Write the ImageInfo and format-specific information for the image content of the specified byte array to a string.
        Parameters:
        bytes - A valid array of bytes.
        Returns:
        A valid string.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • dumpImageFile

        public final java.lang.String dumpImageFile​(java.io.File file)
                                             throws ImageReadException,
                                                    java.io.IOException
        Write the ImageInfo and format-specific information for the image content of the specified file to a string.
        Parameters:
        file - A valid file reference.
        Returns:
        A valid string.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • dumpImageFile

        public final java.lang.String dumpImageFile​(ByteSource byteSource)
                                             throws ImageReadException,
                                                    java.io.IOException
        Write the ImageInfo and format-specific information for the image content of the specified byte source to a string.
        Parameters:
        byteSource - A valid byte source.
        Returns:
        A valid string.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • dumpImageFile

        public boolean dumpImageFile​(java.io.PrintWriter pw,
                                     ByteSource byteSource)
                              throws ImageReadException,
                                     java.io.IOException
        Write the ImageInfo and format-specific information for the image content of the specified byte source to a PrintWriter
        Parameters:
        byteSource - A valid byte source.
        Returns:
        A valid PrintWriter.
        Throws:
        ImageReadException - In the event that the the specified content does not conform to the format of the specific parser implementation.
        java.io.IOException - In the event of unsuccessful read or access operation.
      • getName

        public abstract java.lang.String getName()
        Get a descriptive name for the implementation of an ImageParser.
        Returns:
        a valid, subject-matter-specific string.
      • getDefaultExtension

        public abstract java.lang.String getDefaultExtension()
        Get the default extension for the format specified by an implementation of ImageParser. Some parsers can support more than one extension (i.e. .JPEG, .JPG; .TIF, .TIFF, etc.).
        Returns:
        A valid string.
      • canAcceptType

        public boolean canAcceptType​(ImageFormat type)
        Indicates whether the ImageParser implementation can accept the specified format
        Parameters:
        type - An instance of ImageFormat.
        Returns:
        If the parser can accept the format, true; otherwise, false.
      • isStrict

        public static boolean isStrict​(java.util.Map<java.lang.String,​java.lang.Object> params)
        A utility method to search a params specification and determine whether it contains the ImagingConstants.PARAM_KEY_STRICT specification. Intended for internal use by ImageParser implementations.
        Parameters:
        params - A valid Map object (or a null).
        Returns:
        If the params specify strict format compliance, true; otherwise, false.