public abstract class Sanselan extends Object implements SanselanConstants
Almost all of the Sanselan library's core functionality can be accessed through it's methods.
All of Sanselan's methods are static.
See the source of the SampleUsage class and other classes in the org.apache.sanselan.sampleUsage package for examples.
org.apache.sanselan.sampleUsage.SampleUsage
BUFFERED_IMAGE_FACTORY, PARAM_KEY_COMPRESSION, PARAM_KEY_FILENAME, PARAM_KEY_FORMAT, PARAM_KEY_READ_THUMBNAILS, PARAM_KEY_STRICT, PARAM_KEY_VERBOSE, PARAM_KEY_XMP_XML
Constructor and Description |
---|
Sanselan() |
Modifier and Type | Method and Description |
---|---|
static String |
dumpImageFile(byte[] bytes)
Returns a description of the image's structure.
|
static String |
dumpImageFile(File file)
Returns a description of the image file's structure.
|
static ArrayList |
getAllBufferedImages(byte[] bytes)
Returns all images contained in an image.
|
static ArrayList |
getAllBufferedImages(File file)
Returns all images contained in an image file.
|
static ArrayList |
getAllBufferedImages(InputStream is,
String filename)
Returns all images contained in an image.
|
static BufferedImage |
getBufferedImage(byte[] bytes)
Reads the first image from an image file as a BufferedImage.
|
static BufferedImage |
getBufferedImage(byte[] bytes,
Map params)
Reads the first image from an image file as a BufferedImage.
|
static BufferedImage |
getBufferedImage(File file)
Reads the first image from an image file as a BufferedImage.
|
static BufferedImage |
getBufferedImage(File file,
Map params)
Reads the first image from an image file as a BufferedImage.
|
static BufferedImage |
getBufferedImage(InputStream is)
Reads the first image from an InputStream as a BufferedImage.
|
static BufferedImage |
getBufferedImage(InputStream is,
Map params)
Reads the first image from an InputStream as a BufferedImage.
|
static FormatCompliance |
getFormatCompliance(byte[] bytes) |
static FormatCompliance |
getFormatCompliance(File file) |
static ICC_Profile |
getICCProfile(byte[] bytes)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static ICC_Profile |
getICCProfile(byte[] bytes,
Map params)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
protected static ICC_Profile |
getICCProfile(ByteSource byteSource,
Map params) |
static ICC_Profile |
getICCProfile(File file)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static ICC_Profile |
getICCProfile(File file,
Map params)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static ICC_Profile |
getICCProfile(InputStream is,
String filename)
Extracts an ICC Profile (if present) from JPEG, PNG, PSD (Photoshop) and
TIFF images.
|
static ICC_Profile |
getICCProfile(InputStream is,
String filename,
Map 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,
Map params)
Extracts the raw bytes of an ICC Profile (if present) from JPEG, PNG, PSD
(Photoshop) and TIFF images.
|
static byte[] |
getICCProfileBytes(File file)
Extracts the raw bytes of an ICC Profile (if present) from JPEG, PNG, PSD
(Photoshop) and TIFF images.
|
static byte[] |
getICCProfileBytes(File file,
Map 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,
Map params)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(File file)
Parses the "image info" of an image file.
|
static ImageInfo |
getImageInfo(File file,
Map params)
Parses the "image info" of an image file.
|
static ImageInfo |
getImageInfo(InputStream is,
String filename)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(InputStream is,
String filename,
Map params)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(String filename,
byte[] bytes)
Parses the "image info" of an image.
|
static ImageInfo |
getImageInfo(String filename,
byte[] bytes,
Map params)
Parses the "image info" of an image.
|
static Dimension |
getImageSize(byte[] bytes)
Determines the width and height of an image.
|
static Dimension |
getImageSize(byte[] bytes,
Map params)
Determines the width and height of an image.
|
static Dimension |
getImageSize(ByteSource byteSource,
Map params) |
static Dimension |
getImageSize(File file)
Determines the width and height of an image file.
|
static Dimension |
getImageSize(File file,
Map params)
Determines the width and height of an image file.
|
static Dimension |
getImageSize(InputStream is,
String filename)
Determines the width and height of an image.
|
static Dimension |
getImageSize(InputStream is,
String filename,
Map params)
Determines the width and height of an image.
|
static IImageMetadata |
getMetadata(byte[] bytes)
Parses the metadata of an image.
|
static IImageMetadata |
getMetadata(byte[] bytes,
Map params)
Parses the metadata of an image.
|
static IImageMetadata |
getMetadata(File file)
Parses the metadata of an image file.
|
static IImageMetadata |
getMetadata(File file,
Map params)
Parses the metadata of an image file.
|
static IImageMetadata |
getMetadata(InputStream is,
String filename)
Parses the metadata of an image file.
|
static IImageMetadata |
getMetadata(InputStream is,
String filename,
Map params)
Parses the metadata of an image file.
|
static String |
getXmpXml(byte[] bytes)
Determines the width and height of an image.
|
static String |
getXmpXml(byte[] bytes,
Map params)
Determines the width and height of an image.
|
static String |
getXmpXml(ByteSource byteSource,
Map params)
Extracts embedded XML metadata as XML string.
|
static String |
getXmpXml(File file)
Extracts embedded XML metadata as XML string.
|
static String |
getXmpXml(File file,
Map params)
Extracts embedded XML metadata as XML string.
|
static String |
getXmpXml(InputStream is,
String filename)
Determines the width and height of an image.
|
static String |
getXmpXml(InputStream is,
String filename,
Map params)
Determines the width and height of an image.
|
static ImageFormat |
guessFormat(byte[] bytes)
Tries to guess what the image type (if any) of data based on the file's
"magic numbers," the first bytes of the data.
|
static ImageFormat |
guessFormat(ByteSource byteSource) |
static ImageFormat |
guessFormat(File file)
Tries to guess what the image type (if any) of a file based on the file's
"magic numbers," the first bytes of the file.
|
static boolean |
hasImageFileExtension(File file)
Tries to guess whether a file contains an image based on its file
extension.
|
static boolean |
hasImageFileExtension(String filename)
Tries to guess whether a filename represents an image based on its file
extension.
|
static void |
writeImage(BufferedImage src,
File file,
ImageFormat format,
Map params)
Writes a BufferedImage to a file.
|
static void |
writeImage(BufferedImage src,
OutputStream os,
ImageFormat format,
Map params)
Writes a BufferedImage to an OutputStream.
|
static byte[] |
writeImageToBytes(BufferedImage src,
ImageFormat format,
Map params)
Writes a BufferedImage to a byte array.
|
public static boolean hasImageFileExtension(File file)
Returns true if the file has a file extension associated with a file format, such as .jpg or .gif.
file
- File which may contain an image.public static boolean hasImageFileExtension(String filename)
Returns true if the filename has a file extension associated with a file format, such as .jpg or .gif.
filename
- String representing name of file which may contain an image.public static ImageFormat guessFormat(byte[] bytes) throws ImageReadException, IOException
bytes
- Byte array containing an image file.ImageReadException
IOException
public static ImageFormat guessFormat(File file) throws ImageReadException, IOException
file
- File containing image data.ImageReadException
IOException
public static ImageFormat guessFormat(ByteSource byteSource) throws ImageReadException, IOException
ImageReadException
IOException
public static ICC_Profile getICCProfile(byte[] bytes) throws ImageReadException, IOException
bytes
- Byte array containing an image file.ImageReadException
IOException
public static ICC_Profile getICCProfile(byte[] bytes, Map params) throws ImageReadException, IOException
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static ICC_Profile getICCProfile(InputStream is, String filename) throws ImageReadException, IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
IOException
public static ICC_Profile getICCProfile(InputStream is, String filename, Map params) throws ImageReadException, IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static ICC_Profile getICCProfile(File file) throws ImageReadException, IOException
file
- File containing image data.ImageReadException
IOException
public static ICC_Profile getICCProfile(File file, Map params) throws ImageReadException, IOException
file
- File containing image data.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
protected static ICC_Profile getICCProfile(ByteSource byteSource, Map params) throws ImageReadException, IOException
ImageReadException
IOException
public static byte[] getICCProfileBytes(byte[] bytes) throws ImageReadException, IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
bytes
- Byte array containing an image file.ImageReadException
IOException
IccProfileParser
,
ICC_Profile
public static byte[] getICCProfileBytes(byte[] bytes, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
IccProfileParser
,
ICC_Profile
public static byte[] getICCProfileBytes(File file) throws ImageReadException, IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
file
- File containing image data.ImageReadException
IOException
IccProfileParser
,
ICC_Profile
public static byte[] getICCProfileBytes(File file, Map params) throws ImageReadException, IOException
To parse the result use IccProfileParser or ICC_Profile.getInstance(bytes).
file
- File containing image data.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
IccProfileParser
,
ICC_Profile
public static ImageInfo getImageInfo(String filename, byte[] bytes, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
ImageInfo
public static ImageInfo getImageInfo(String filename, byte[] bytes) throws ImageReadException, 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
IOException
ImageInfo
public static ImageInfo getImageInfo(InputStream is, String filename) throws ImageReadException, 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
IOException
ImageInfo
public static ImageInfo getImageInfo(InputStream is, String filename, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
ImageInfo
public static ImageInfo getImageInfo(byte[] bytes) throws ImageReadException, 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
IOException
ImageInfo
public static ImageInfo getImageInfo(byte[] bytes, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
ImageInfo
public static ImageInfo getImageInfo(File file, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
ImageInfo
public static ImageInfo getImageInfo(File file) throws ImageReadException, 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
IOException
ImageInfo
public static Dimension getImageSize(InputStream is, String filename) throws ImageReadException, IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
IOException
public static Dimension getImageSize(InputStream is, String filename, Map params) throws ImageReadException, IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static Dimension getImageSize(byte[] bytes) throws ImageReadException, IOException
bytes
- Byte array containing an image file.ImageReadException
IOException
public static Dimension getImageSize(byte[] bytes, Map params) throws ImageReadException, IOException
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static Dimension getImageSize(File file) throws ImageReadException, IOException
file
- File containing image data.ImageReadException
IOException
public static Dimension getImageSize(File file, Map params) throws ImageReadException, IOException
file
- File containing image data.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static Dimension getImageSize(ByteSource byteSource, Map params) throws ImageReadException, IOException
ImageReadException
IOException
public static String getXmpXml(InputStream is, String filename) throws ImageReadException, IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
IOException
public static String getXmpXml(InputStream is, String filename, Map params) throws ImageReadException, IOException
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static String getXmpXml(byte[] bytes) throws ImageReadException, IOException
bytes
- Byte array containing an image file.ImageReadException
IOException
public static String getXmpXml(byte[] bytes, Map params) throws ImageReadException, IOException
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static String getXmpXml(File file) throws ImageReadException, IOException
file
- File containing image data.ImageReadException
IOException
public static String getXmpXml(File file, Map params) throws ImageReadException, IOException
file
- File containing image data.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static String getXmpXml(ByteSource byteSource, Map params) throws ImageReadException, IOException
file
- File containing image data.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
public static IImageMetadata getMetadata(byte[] bytes) throws ImageReadException, 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
IOException
IImageMetadata
public static IImageMetadata getMetadata(byte[] bytes, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
IImageMetadata
public static IImageMetadata getMetadata(InputStream is, String filename) throws ImageReadException, 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
IOException
IImageMetadata
public static IImageMetadata getMetadata(InputStream is, String filename, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
IImageMetadata
public static IImageMetadata getMetadata(File file) throws ImageReadException, 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
IOException
IImageMetadata
public static IImageMetadata getMetadata(File file, Map params) throws ImageReadException, 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 SanselanConstants.ImageReadException
IOException
IImageMetadata
public static String dumpImageFile(byte[] bytes) throws ImageReadException, IOException
Useful for exploring format-specific details of image files.
bytes
- Byte array containing an image file.ImageReadException
IOException
public static String dumpImageFile(File file) throws ImageReadException, IOException
Useful for exploring format-specific details of image files.
file
- File containing image data.ImageReadException
IOException
public static FormatCompliance getFormatCompliance(byte[] bytes) throws ImageReadException, IOException
ImageReadException
IOException
public static FormatCompliance getFormatCompliance(File file) throws ImageReadException, IOException
ImageReadException
IOException
public static ArrayList getAllBufferedImages(InputStream is, String filename) throws ImageReadException, IOException
Useful for image formats such as GIF and ICO in which a single file may contain multiple images.
is
- InputStream from which to read image data.filename
- Filename associated with image data (optional).ImageReadException
IOException
public static ArrayList getAllBufferedImages(byte[] bytes) throws ImageReadException, IOException
Useful for image formats such as GIF and ICO in which a single file may contain multiple images.
bytes
- Byte array containing an image file.ImageReadException
IOException
public static ArrayList getAllBufferedImages(File file) throws ImageReadException, IOException
Useful for image formats such as GIF and ICO in which a single file may contain multiple images.
file
- File containing image data.ImageReadException
IOException
public static BufferedImage getBufferedImage(InputStream is) throws ImageReadException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
is
- InputStream to read image data from.ImageReadException
IOException
SanselanConstants
public static BufferedImage getBufferedImage(InputStream is, Map params) throws ImageReadException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
is
- InputStream to read image data from.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
SanselanConstants
public static BufferedImage getBufferedImage(byte[] bytes) throws ImageReadException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
bytes
- Byte array containing an image file.ImageReadException
IOException
SanselanConstants
public static BufferedImage getBufferedImage(byte[] bytes, Map params) throws ImageReadException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
bytes
- Byte array containing an image file.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
SanselanConstants
public static BufferedImage getBufferedImage(File file) throws ImageReadException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
file
- File containing image data.ImageReadException
IOException
SanselanConstants
public static BufferedImage getBufferedImage(File file, Map params) throws ImageReadException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
file
- File containing image data.params
- Map of optional parameters, defined in SanselanConstants.ImageReadException
IOException
SanselanConstants
public static void writeImage(BufferedImage src, File file, ImageFormat format, Map params) throws ImageWriteException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
src
- The BufferedImage to be written.file
- File to write to.format
- The ImageFormat to use.params
- Map of optional parameters, defined in SanselanConstants.ImageWriteException
IOException
SanselanConstants
public static byte[] writeImageToBytes(BufferedImage src, ImageFormat format, Map params) throws ImageWriteException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
src
- The BufferedImage to be written.format
- The ImageFormat to use.params
- Map of optional parameters, defined in SanselanConstants.ImageWriteException
IOException
SanselanConstants
public static void writeImage(BufferedImage src, OutputStream os, ImageFormat format, Map params) throws ImageWriteException, IOException
(TODO: elaborate here.)
Sanselan can only read image info, metadata and ICC profiles from all image formats. However, note that the library cannot currently read or write JPEG image data. PSD (Photoshop) files can only be partially read and cannot be written. All other formats (PNG, GIF, TIFF, BMP, etc.) are fully supported.
src
- The BufferedImage to be written.os
- The OutputStream to write to.format
- The ImageFormat to use.params
- Map of optional parameters, defined in SanselanConstants.ImageWriteException
IOException
SanselanConstants
Copyright © 2007-2012. All Rights Reserved.