public final class Imaging
extends java.lang.Object
Almost all of the Apache Commons Imaging library's core functionality can be accessed through the methods provided by this class. The use of the Imaging class is similar to the Java API's ImageIO class, though Imaging supports formats and options not included in the standard Java API.
All of methods provided by the Imaging class are declared static.
The Apache Commons Imaging package is a pure Java implementation.
While the Apache Commons Imaging package handles a number of different graphics formats, support for some formats is not yet complete. For the most recent information on support for specific formats, refer to Format Support at the main project development web site.
Some of the methods provided by this class accept an optional params argument that permits the application to specify elements for special handling. If these specifications are not required by the application, the params argument may be omitted (as appropriate) or a null argument may be provided. In image-writing operations, the option parameters may include options such as data-compression type (if any), color model, or other format-specific data representations. The parameters map may also be used to provide EXIF Tags and other metadata to those formats that support them. In image-reading operations, the parameters may include information about special handling in reading the image data.
Optional parameters are specified using a Map object (typically, a Java HashMap) to specify a set of keys and values for input. The specification for support keys is provided by the ImagingConstants interface as well as by format-specific interfaces such as JpegContants or TiffConstants.
See the source of the SampleUsage class and other classes in the org.apache.commons.imaging.examples package for examples.
Modifier and Type | Method and Description |
---|---|
static 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.
|
static 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.
|
static 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).
|
static java.util.List<java.awt.image.BufferedImage> |
getAllBufferedImages(java.io.File file)
Gets all images specified by the file (some
formats may include multiple images within a single data source).
|
static java.util.List<java.awt.image.BufferedImage> |
getAllBufferedImages(java.io.InputStream is,
java.lang.String filename)
Gets all images specified by the InputStream (some
formats may include multiple images within a single data source).
|
static java.awt.image.BufferedImage |
getBufferedImage(byte[] bytes)
Reads the first image from a byte array.
|
static java.awt.image.BufferedImage |
getBufferedImage(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Reads the first image from a byte array
using data-processing options specified through a parameters
map.
|
static java.awt.image.BufferedImage |
getBufferedImage(java.io.File file)
Reads the first image from a file.
|
static java.awt.image.BufferedImage |
getBufferedImage(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Reads the first image from a file
using data-processing options specified through a parameters
map.
|
static java.awt.image.BufferedImage |
getBufferedImage(java.io.InputStream is)
Reads the first image from an InputStream.
|
static java.awt.image.BufferedImage |
getBufferedImage(java.io.InputStream is,
java.util.Map<java.lang.String,java.lang.Object> params)
Reads the first image from an InputStream
using data-processing options specified through a parameters
map.
|
static FormatCompliance |
getFormatCompliance(byte[] bytes)
Attempts to determine the image format of the specified data and
evaluates its format compliance.
|
static FormatCompliance |
getFormatCompliance(java.io.File file)
Attempts to determine the image format of the specified data and
evaluates its format compliance.
|
static java.awt.color.ICC_Profile |
getICCProfile(byte[] bytes)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static java.awt.color.ICC_Profile |
getICCProfile(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static java.awt.color.ICC_Profile |
getICCProfile(java.io.File file)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static java.awt.color.ICC_Profile |
getICCProfile(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static java.awt.color.ICC_Profile |
getICCProfile(java.io.InputStream is,
java.lang.String filename)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static java.awt.color.ICC_Profile |
getICCProfile(java.io.InputStream is,
java.lang.String filename,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static byte[] |
getICCProfileBytes(byte[] bytes)
Extracts the raw bytes of an ICC Profile (if present) from JPEG, PNG, PSD
(Photoshop) and TIFF images.
|
static byte[] |
getICCProfileBytes(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts the raw bytes of an ICC Profile (if present) from JPEG, PNG, PSD
(Photoshop) and TIFF images.
|
static byte[] |
getICCProfileBytes(java.io.File file)
Extracts the raw bytes of an ICC Profile (if present) from JPEG, PNG, PSD
(Photoshop) and TIFF images.
|
static byte[] |
getICCProfileBytes(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts the raw bytes of an ICC Profile (if present) from JPEG, PNG, PSD
(Photoshop) and TIFF images.
|
static ImageInfo |
getImageInfo(byte[] bytes)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(java.io.File file)
Parses the "image info" of an image file.
|
static ImageInfo |
getImageInfo(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the "image info" of an image file.
|
static ImageInfo |
getImageInfo(java.io.InputStream is,
java.lang.String filename)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(java.io.InputStream is,
java.lang.String filename,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(java.lang.String filename,
byte[] bytes)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(java.lang.String filename,
byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the "image info" of an image.
|
static java.awt.Dimension |
getImageSize(byte[] bytes)
Determines the width and height of an image.
|
static java.awt.Dimension |
getImageSize(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Determines the width and height of an image.
|
static java.awt.Dimension |
getImageSize(ByteSource byteSource,
java.util.Map<java.lang.String,java.lang.Object> params) |
static java.awt.Dimension |
getImageSize(java.io.File file)
Determines the width and height of an image file.
|
static java.awt.Dimension |
getImageSize(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Determines the width and height of an image file.
|
static java.awt.Dimension |
getImageSize(java.io.InputStream is,
java.lang.String filename)
Determines the width and height of an image.
|
static java.awt.Dimension |
getImageSize(java.io.InputStream is,
java.lang.String filename,
java.util.Map<java.lang.String,java.lang.Object> params)
Determines the width and height of an image.
|
static ImageMetadata |
getMetadata(byte[] bytes)
Parses the metadata of an image.
|
static ImageMetadata |
getMetadata(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the metadata of an image.
|
static ImageMetadata |
getMetadata(java.io.File file)
Parses the metadata of an image file.
|
static ImageMetadata |
getMetadata(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the metadata of an image file.
|
static ImageMetadata |
getMetadata(java.io.InputStream is,
java.lang.String filename)
Parses the metadata of an image file.
|
static ImageMetadata |
getMetadata(java.io.InputStream is,
java.lang.String filename,
java.util.Map<java.lang.String,java.lang.Object> params)
Parses the metadata of an image file.
|
static java.lang.String |
getXmpXml(byte[] bytes)
Extracts the embedded XML metadata as an XML string.
|
static java.lang.String |
getXmpXml(byte[] bytes,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts the embedded XML metadata as an XML string.
|
static java.lang.String |
getXmpXml(ByteSource byteSource,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts the embedded XML metadata as an XML string.
|
static java.lang.String |
getXmpXml(java.io.File file)
Extracts the embedded XML metadata as an XML string.
|
static java.lang.String |
getXmpXml(java.io.File file,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts the embedded XML metadata as an XML string.
|
static java.lang.String |
getXmpXml(java.io.InputStream is,
java.lang.String filename)
Extracts the embedded XML metadata as an XML string.
|
static java.lang.String |
getXmpXml(java.io.InputStream is,
java.lang.String filename,
java.util.Map<java.lang.String,java.lang.Object> params)
Extracts the embedded XML metadata as an XML string.
|
static ImageFormat |
guessFormat(byte[] bytes)
Attempts to determine the image format of a file based on its
"magic numbers," the first bytes of the data.
|
static ImageFormat |
guessFormat(ByteSource byteSource)
Attempts to determine the image format of a file based on its
"magic numbers," the first bytes of the data.
|
static ImageFormat |
guessFormat(java.io.File file)
Attempts to determine the image format of a file based on its
"magic numbers," the first bytes of the data.
|
static boolean |
hasImageFileExtension(java.io.File file)
Attempts to determine if a file contains an image recorded in
a supported graphics format based on its file-name extension
(for example ".jpg", ".gif", ".png", etc.).
|
static boolean |
hasImageFileExtension(java.lang.String filename)
Attempts to determine if a file contains an image recorded in
a supported graphics format based on its file-name extension
(for example ".jpg", ".gif", ".png", etc.).
|
static void |
writeImage(java.awt.image.BufferedImage src,
java.io.File file,
ImageFormat format,
java.util.Map<java.lang.String,java.lang.Object> params)
Writes the content of a BufferedImage to a file using the specified
image format.
|
static void |
writeImage(java.awt.image.BufferedImage src,
java.io.OutputStream os,
ImageFormat format,
java.util.Map<java.lang.String,java.lang.Object> params)
Writes the content of a BufferedImage to an OutputStream using the specified
image format.
|
static byte[] |
writeImageToBytes(java.awt.image.BufferedImage src,
ImageFormat format,
java.util.Map<java.lang.String,java.lang.Object> params)
Writes the content of a BufferedImage to a byte array using the specified
image format.
|
public static boolean hasImageFileExtension(java.io.File file)
file
- A valid File object providing a reference to
a file that may contain an image.public static boolean hasImageFileExtension(java.lang.String filename)
filename
- A valid string representing name of file
which may contain an image.public static ImageFormat guessFormat(byte[] bytes) throws ImageReadException, java.io.IOException
Many graphics format specify identifying byte values that appear at the beginning of the data file. This method checks for such identifying elements and returns a ImageFormat enumeration indicating what it detects. Note that this method can return "false positives" in cases where non-image files begin with the specified byte values.
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
public static ImageFormat guessFormat(java.io.File file) throws ImageReadException, java.io.IOException
Many graphics formats specify identifying byte values that appear at the beginning of the data file. This method checks for such identifying elements and returns a ImageFormat enumeration indicating what it detects. Note that this method can return "false positives" in cases where non-image files begin with the specified byte values.
file
- File containing image data.ImageReadException
java.io.IOException
public static ImageFormat guessFormat(ByteSource byteSource) throws ImageReadException, java.io.IOException
Many graphics formats specify identifying byte values that appear at the beginning of the data file. This method checks for such identifying elements and returns a ImageFormat enumeration indicating what it detects. Note that this method can return "false positives" in cases where non-image files begin with the specified byte values.
byteSource
- a valid ByteSource object potentially supplying
data for an image.ImageReadException
- in the event of an unsuccessful
attempt to read the image datajava.io.IOException
- in the event of an unrecoverable I/O condition.public static java.awt.color.ICC_Profile getICCProfile(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
public static java.awt.color.ICC_Profile getICCProfile(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.awt.color.ICC_Profile getICCProfile(java.io.InputStream is, java.lang.String filename) throws ImageReadException, java.io.IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
java.io.IOException
public static java.awt.color.ICC_Profile getICCProfile(java.io.InputStream is, java.lang.String filename, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.awt.color.ICC_Profile getICCProfile(java.io.File file) throws ImageReadException, java.io.IOException
file
- File containing image data.ImageReadException
java.io.IOException
public static java.awt.color.ICC_Profile getICCProfile(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
file
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static byte[] getICCProfileBytes(byte[] bytes) throws ImageReadException, java.io.IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
IccProfileParser
,
ICC_Profile
public static byte[] getICCProfileBytes(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
IccProfileParser
,
ICC_Profile
public static byte[] getICCProfileBytes(java.io.File file) throws ImageReadException, java.io.IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
file
- File containing image data.ImageReadException
java.io.IOException
IccProfileParser
,
ICC_Profile
public static byte[] getICCProfileBytes(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
file
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
IccProfileParser
,
ICC_Profile
public static ImageInfo getImageInfo(java.lang.String filename, byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
filename
- String.bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(java.lang.String filename, byte[] bytes) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
filename
- String.bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(java.io.InputStream is, java.lang.String filename) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(java.io.InputStream is, java.lang.String filename, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(byte[] bytes) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
file
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageInfo
public static ImageInfo getImageInfo(java.io.File file) throws ImageReadException, java.io.IOException
"Image info" is a summary of basic information about the image such as: width, height, file format, bit depth, color type, etc.
Not to be confused with "image metadata."
file
- File containing image data.ImageReadException
java.io.IOException
ImageInfo
public static java.awt.Dimension getImageSize(java.io.InputStream is, java.lang.String filename) throws ImageReadException, java.io.IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
java.io.IOException
public static java.awt.Dimension getImageSize(java.io.InputStream is, java.lang.String filename, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.awt.Dimension getImageSize(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
public static java.awt.Dimension getImageSize(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.awt.Dimension getImageSize(java.io.File file) throws ImageReadException, java.io.IOException
file
- File containing image data.ImageReadException
java.io.IOException
public static java.awt.Dimension getImageSize(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
file
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.awt.Dimension getImageSize(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(java.io.InputStream is, java.lang.String filename) throws ImageReadException, java.io.IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(java.io.InputStream is, java.lang.String filename, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(java.io.File file) throws ImageReadException, java.io.IOException
file
- File containing image data.ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
file
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static java.lang.String getXmpXml(ByteSource byteSource, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
byteSource
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
public static ImageMetadata getMetadata(byte[] bytes) throws ImageReadException, java.io.IOException
JPEG/JFIF files may contain EXIF and/or IPTC metadata. PNG files may contain comments. TIFF files may contain metadata.
The instance of IImageMetadata returned by getMetadata() should be upcast (depending on image format).
Not to be confused with "image info."
bytes
- Byte array containing an image file.ImageReadException
java.io.IOException
ImageMetadata
public static ImageMetadata getMetadata(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
JPEG/JFIF files may contain EXIF and/or IPTC metadata. PNG files may contain comments. TIFF files may contain metadata.
The instance of IImageMetadata returned by getMetadata() should be upcast (depending on image format).
Not to be confused with "image info."
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageMetadata
public static ImageMetadata getMetadata(java.io.InputStream is, java.lang.String filename) throws ImageReadException, java.io.IOException
JPEG/JFIF files may contain EXIF and/or IPTC metadata. PNG files may contain comments. TIFF files may contain metadata.
The instance of IImageMetadata returned by getMetadata() should be upcast (depending on image format).
Not to be confused with "image info."
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
java.io.IOException
ImageMetadata
public static ImageMetadata getMetadata(java.io.InputStream is, java.lang.String filename, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
JPEG/JFIF files may contain EXIF and/or IPTC metadata. PNG files may contain comments. TIFF files may contain metadata.
The instance of IImageMetadata returned by getMetadata() should be upcast (depending on image format).
Not to be confused with "image info."
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageMetadata
public static ImageMetadata getMetadata(java.io.File file) throws ImageReadException, java.io.IOException
JPEG/JFIF files may contain EXIF and/or IPTC metadata. PNG files may contain comments. TIFF files may contain metadata.
The instance of IImageMetadata returned by getMetadata() should be upcast (depending on image format).
Not to be confused with "image info."
file
- File containing image data.ImageReadException
java.io.IOException
ImageMetadata
public static ImageMetadata getMetadata(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
JPEG/JFIF files may contain EXIF and/or IPTC metadata. PNG files may contain comments. TIFF files may contain metadata.
The instance of IImageMetadata returned by getMetadata() should be upcast (depending on image format).
Not to be confused with "image info."
file
- File containing image data.params
- Map of optional parameters, defined in ImagingConstants.ImageReadException
java.io.IOException
ImageMetadata
public static 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 static 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 static FormatCompliance getFormatCompliance(byte[] bytes) throws ImageReadException, java.io.IOException
bytes
- a valid array of bytes containing image data.ImageReadException
- in the event of unreadable data.java.io.IOException
- in the event of an unrecoverable I/O condition.public static FormatCompliance getFormatCompliance(java.io.File file) throws ImageReadException, java.io.IOException
file
- valid file containing image dataImageReadException
- in the event of unreadable data.java.io.IOException
- in the event of an unrecoverable I/O condition.public static java.util.List<java.awt.image.BufferedImage> getAllBufferedImages(java.io.InputStream is, java.lang.String filename) throws ImageReadException, java.io.IOException
is
- A valid InputStreamImageReadException
- 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 static java.util.List<java.awt.image.BufferedImage> getAllBufferedImages(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 read or
access operation.public static java.util.List<java.awt.image.BufferedImage> getAllBufferedImages(java.io.File file) throws ImageReadException, java.io.IOException
file
- A reference to a valid data 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 static java.awt.image.BufferedImage getBufferedImage(java.io.InputStream is) throws ImageReadException, java.io.IOException
For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
is
- a valid ImageStream from which to read data.ImageReadException
- in the event of a processing error
while reading an image (i.e. a format violation, etc.).java.io.IOException
- in the event of an unrecoverable I/O exception.public static java.awt.image.BufferedImage getBufferedImage(java.io.InputStream is, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
is
- a valid ImageStream from which to read data.params
- an optional parameters map specifying optionsImageReadException
- in the event of a processing error
while reading an image (i.e. a format violation, etc.).java.io.IOException
- in the event of an unrecoverable I/O exception.public static java.awt.image.BufferedImage getBufferedImage(byte[] bytes) throws ImageReadException, java.io.IOException
For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
bytes
- a valid array of bytes from which to read data.ImageReadException
- in the event of a processing error
while reading an image (i.e. a format violation, etc.).java.io.IOException
- in the event of an unrecoverable I/O exception.public static java.awt.image.BufferedImage getBufferedImage(byte[] bytes, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
bytes
- a valid array of bytes from which to read data.params
- an optional parameters map specifying options.ImageReadException
- in the event of a processing error
while reading an image (i.e. a format violation, etc.).java.io.IOException
- in the event of an unrecoverable I/O exception.public static java.awt.image.BufferedImage getBufferedImage(java.io.File file) throws ImageReadException, java.io.IOException
For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
file
- a valid reference to a file containing image data.ImageReadException
- in the event of a processing error
while reading an image (i.e. a format violation, etc.).java.io.IOException
- in the event of an unrecoverable I/O exception.public static java.awt.image.BufferedImage getBufferedImage(java.io.File file, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageReadException, java.io.IOException
For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
file
- a valid reference to a file containing image data.ImageReadException
- in the event of a processing error
while reading an image (i.e. a format violation, etc.).java.io.IOException
- in the event of an unrecoverable I/O exception.public static void writeImage(java.awt.image.BufferedImage src, java.io.File file, ImageFormat format, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageWriteException, java.io.IOException
Image writing is not supported for all graphics formats. For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
src
- a valid BufferedImage objectfile
- the file to which the output image is to be writtenformat
- the format in which the output image is to be writtenparams
- an optional parameters map (nulls permitted)ImageWriteException
- in the event of a format violation,
unsupported image format, etc.java.io.IOException
- in the event of an unrecoverable I/O exception.ImagingConstants
public static byte[] writeImageToBytes(java.awt.image.BufferedImage src, ImageFormat format, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageWriteException, java.io.IOException
Image writing is not supported for all graphics formats. For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
src
- a valid BufferedImage objectformat
- the format in which the output image is to be writtenparams
- an optional parameters map (nulls permitted)ImageWriteException
- in the event of a format violation,
unsupported image format, etc.java.io.IOException
- in the event of an unrecoverable I/O exception.ImagingConstants
public static void writeImage(java.awt.image.BufferedImage src, java.io.OutputStream os, ImageFormat format, java.util.Map<java.lang.String,java.lang.Object> params) throws ImageWriteException, java.io.IOException
Image writing is not supported for all graphics formats. For the most recent information on support for specific formats, refer to Format Support at the main project development web site. While the Apache Commons Imaging package does not fully support all formats, it can read image info, metadata and ICC profiles from all image formats that provide this data.
src
- a valid BufferedImage objectos
- the OutputStream to which the output image is to be writtenformat
- the format in which the output image is to be writtenparams
- an optional parameters map (nulls permitted)ImageWriteException
- in the event of a format violation,
unsupported image format, etc.java.io.IOException
- in the event of an unrecoverable I/O exception.ImagingConstants
Copyright © 2010 - 2020 Adobe. All Rights Reserved