public abstract class ImageParser extends BinaryFileParser
Additionally, developers creating or enhancing classes derived from ImageParser are encouraged to include such checks in their code.
Constructor and Description |
---|
ImageParser() |
Modifier and Type | Method and 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(ByteSource byteSource)
Write the ImageInfo and format-specific information for the image
content of the specified byte source 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.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(ByteSource byteSource)
Gets all images specified by the byte source (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).
|
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).
|
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).
|
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.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(ByteSource byteSource)
Determines the format compliance of the content of the supplied byte
source 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.
|
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.
|
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.
|
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.
|
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(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.
|
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.
|
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.
|
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.
|
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.
|
ImageMetadata |
getMetadata(byte[] bytes)
Get image metadata from the specified array of bytes.
|
ImageMetadata |
getMetadata(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Get image metadata from the specified array of bytes.
|
ImageMetadata |
getMetadata(ByteSource byteSource)
Get image metadata from the specified byte source.
|
abstract ImageMetadata |
getMetadata(ByteSource byteSource,
java.util.Map<java.lang.String,java.lang.Object> params)
Get image metadata from the specified byte source.
|
ImageMetadata |
getMetadata(java.io.File file)
Get image metadata from the specified file.
|
ImageMetadata |
getMetadata(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Get image metadata from the specified file.
|
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.
|
getByteOrder, getDebug, setDebug
public static ImageParser[] getAllImageParsers()
public final ImageMetadata getMetadata(ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid byte source.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.public abstract ImageMetadata getMetadata(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
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.
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).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.public final ImageMetadata getMetadata(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid array of bytesImageReadException
- 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.public final ImageMetadata getMetadata(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
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.
bytes
- A valid array of bytesparams
- Optional instructions for special-handling or
interpretation of the input data (null objects are permitted and
must be supported by implementations).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.public final ImageMetadata getMetadata(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid reference to a file.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.public final ImageMetadata getMetadata(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
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.
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).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.public abstract ImageInfo getImageInfo(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
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.
byteSource
- A valid ByteSource objectparams
- Optional instructions for special-handling or interpretation
of the input data (null objects are permitted and
must be supported by implementations).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.public final ImageInfo getImageInfo(ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid ByteSource objectImageReadException
- 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.public final ImageInfo getImageInfo(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
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.
bytes
- A valid array of bytesparams
- Optional instructions for special-handling or
interpretation of the input data (null objects are permitted and
must be supported by implementations).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.public final ImageInfo getImageInfo(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
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.
file
- A valid File objectparams
- Optional instructions for special-handling or
interpretation of the input data (null objects are permitted and
must be supported by implementations).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.public FormatCompliance getFormatCompliance(ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid instance of ByteSourceImageReadException
- may be thrown by sub-classesjava.io.IOException
- may be thrown by sub-classespublic final FormatCompliance getFormatCompliance(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid byte array.ImageReadException
- may be thrown by sub-classesjava.io.IOException
- may be thrown by sub-classespublic final FormatCompliance getFormatCompliance(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid reference to a file.ImageReadException
- may be thrown by sub-classesjava.io.IOException
- may be thrown by sub-classespublic java.util.List<java.awt.image.BufferedImage> getAllBufferedImages(ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid instance of ByteSource.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.public final java.util.List<java.awt.image.BufferedImage> getAllBufferedImages(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid byte arrayImageReadException
- 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.public final java.util.List<java.awt.image.BufferedImage> getAllBufferedImages(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid reference to a file.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.public abstract java.awt.image.BufferedImage getBufferedImage(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
byteSource
- A valid instance of ByteSourceparams
- Optional instructions for special-handling or
interpretation of the input data (null objects are permitted and
must be supported by implementations).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.public final java.awt.image.BufferedImage getBufferedImage(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
bytes
- A valid byte arrayparams
- Optional instructions for special-handling or
interpretation of the input data (null objects are permitted and
must be supported by implementations).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.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
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).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.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
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).
src
- An image giving the source content for outputos
- A valid output stream for storing the formatted imageparams
- A non-null Map implementation supplying optional,
format-specific instructions for output
(such as selections for data compression, color models, etc.)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.public final java.awt.Dimension getImageSize(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid byte array.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.public final java.awt.Dimension getImageSize(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
bytes
- A valid byte array.params
- Optional instructions for special-handling or
interpretation of the input data.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.public final java.awt.Dimension getImageSize(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid reference to a file.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.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
file
- A valid reference to a file.params
- Optional instructions for special-handling or
interpretation of the input data.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.public abstract java.awt.Dimension getImageSize(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
byteSource
- A valid reference to a ByteSource.params
- Optional instructions for special-handling or
interpretation of the input data.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.public abstract java.lang.String getXmpXml(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
byteSource
- A valid reference to a ByteSource.params
- Optional instructions for special-handling or
interpretation of the input data.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.public final byte[] getICCProfileBytes(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid array of bytes.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.public final byte[] getICCProfileBytes(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
bytes
- A valid array of bytes.params
- Optional instructions for special-handling or
interpretation of the input data.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.public final byte[] getICCProfileBytes(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid file reference.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.public final byte[] getICCProfileBytes(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
file
- A valid file reference.params
- Optional instructions for special-handling or
interpretation of the input data.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.public abstract byte[] getICCProfileBytes(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
byteSource
- A valid ByteSource.params
- Optional instructions for special-handling or
interpretation of the input data.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.public final java.lang.String dumpImageFile(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid array of bytes.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.public final java.lang.String dumpImageFile(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid file reference.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.public final java.lang.String dumpImageFile(ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid byte source.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.public boolean dumpImageFile(java.io.PrintWriter pw, ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid byte source.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.public abstract java.lang.String getName()
public abstract java.lang.String getDefaultExtension()
public boolean canAcceptType(ImageFormat type)
type
- An instance of ImageFormat.public static boolean isStrict(java.util.Map<java.lang.String,java.lang.Object> params)
params
- A valid Map object (or a null).Copyright © 2010 - 2020 Adobe. All Rights Reserved