T
- type of parameters used by this image parserpublic abstract class ImageParser<T extends ImagingParameters>
extends org.apache.commons.imaging.common.BinaryFileParser
Many of the methods specified by this class accept an argument of
type T
defining the parameters to be used when
processing an image. For example, some of the output formats permit
of different kinds of image compression or color models. Some of the
reading methods permit the calling application to require strict
format compliance.
Constructor and Description |
---|
ImageParser() |
Modifier and Type | Method and Description |
---|---|
boolean |
canAcceptExtension(java.io.File file)
Indicates whether the ImageParser implementation can accept
the specified file based on its extension.
|
boolean |
canAcceptExtension(java.lang.String fileName)
Indicates whether the ImageParser implementation can accept
the specified file name based on its extension.
|
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 java.util.List<ImageParser<?>> |
getAllImageParsers()
Gets an array of new instances of all image parsers.
|
java.awt.image.BufferedImage |
getBufferedImage(byte[] bytes,
T 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,
T 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,
T 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.
|
abstract T |
getDefaultParameters()
Get a default parameters instance for this parser.
|
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,
T 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,
T params)
Get an array of bytes describing the International Color Consortium (ICC)
specification for the color space of the image contained in the
input byteSource.
|
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,
T 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,
T 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,
T params)
Get image information from the specified ByteSource.
|
ImageInfo |
getImageInfo(java.io.File file,
T 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,
T params)
Get the size of the image described by the specified byte array.
|
abstract java.awt.Dimension |
getImageSize(ByteSource byteSource,
T 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,
T params)
Get the size of the image described by the specified file.
|
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,
T params)
Get image metadata from the specified array of bytes.
|
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,
T params)
Get image metadata from the specified byte source.
|
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,
T params)
Get image metadata from the specified file.
|
abstract java.lang.String |
getName()
Get a descriptive name for the implementation of an ImageParser.
|
void |
writeImage(java.awt.image.BufferedImage src,
java.io.OutputStream os,
T params)
Writes the content of a BufferedImage to the specified output
stream.
|
public static java.util.List<ImageParser<?>> getAllImageParsers()
public abstract T getDefaultParameters()
public final org.apache.commons.imaging.common.ImageMetadata getMetadata(ByteSource byteSource) throws ImageReadException, java.io.IOException
byteSource
- A valid byte source.ImageReadException
- In the event that 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 org.apache.commons.imaging.common.ImageMetadata getMetadata(ByteSource byteSource, T 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 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 org.apache.commons.imaging.common.ImageMetadata getMetadata(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- A valid array of bytesImageReadException
- In the event that 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 org.apache.commons.imaging.common.ImageMetadata getMetadata(byte[] bytes, T 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 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 org.apache.commons.imaging.common.ImageMetadata getMetadata(java.io.File file) throws ImageReadException, java.io.IOException
file
- A valid reference to a file.ImageReadException
- In the event that 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 org.apache.commons.imaging.common.ImageMetadata getMetadata(java.io.File file, T 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 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, T 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 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 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, T 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 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, T 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 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 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 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 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, T 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 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, T 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 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, T 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 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, T 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.
src
- An image giving the source content for outputos
- A valid output stream for storing the formatted imageparams
- optional parameters, defining 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 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, T 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 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 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, T 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 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, T 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 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 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, T 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 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 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, T 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 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, T 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 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 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 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 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
pw
- print writer used for writing the ImageInfobyteSource
- A valid byte source.ImageReadException
- In the event that 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 boolean canAcceptExtension(java.io.File file)
file
- An valid file reference.public final boolean canAcceptExtension(java.lang.String fileName)
fileName
- A valid string giving a file name or file path.Copyright © 2010 - 2023 Adobe. All Rights Reserved