|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dasein.media.ImageIngester
public class ImageIngester
Provides meta-data for images of a variety of formats. Supported formats include:
This class is based on the ImageInfo class originally written
and placed into the public domain by Marco Schmidt. Valtira also places
this class into the public domain. It may therefore be used, distributed,
modified, and otherwise enjoyed without restriction. Its presence in
packages or products from Valtira, however, does not impact the overall
license agreement under which those packages or products are released.
Known limitations:
setDetermineImageNumber(boolean) before calling
ingest().
The complete scan over the GIF file will take additional time.Last modification: $Date: 2006/05/21 20:34:38 $
| Field Summary | |
|---|---|
static int |
COLOR_TYPE_BLACK_AND_WHITE
|
static int |
COLOR_TYPE_GRAYSCALE
|
static int |
COLOR_TYPE_PALETTED
|
static int |
COLOR_TYPE_TRUECOLOR_RGB
|
static int |
COLOR_TYPE_UNKNOWN
|
static int |
FORMAT_BMP
Return value of getFormat() for BMP streams. |
static int |
FORMAT_GIF
Return value of getFormat() for GIF streams. |
static int |
FORMAT_IFF
Return value of getFormat() for IFF streams. |
static int |
FORMAT_JPEG
Return value of getFormat() for JPEG streams. |
static int |
FORMAT_PBM
Return value of getFormat() for PBM streams. |
static int |
FORMAT_PCX
Return value of getFormat() for PCX streams. |
static int |
FORMAT_PGM
Return value of getFormat() for PGM streams. |
static int |
FORMAT_PNG
Return value of getFormat() for PNG streams. |
static int |
FORMAT_PPM
Return value of getFormat() for PPM streams. |
static int |
FORMAT_PSD
Return value of getFormat() for PSD streams. |
static int |
FORMAT_RAS
Return value of getFormat() for RAS streams. |
static int |
FORMAT_SWF
Return value of getFormat() for SWF (Shockwave) streams. |
| Fields inherited from interface org.dasein.media.Ingester |
|---|
EXTENSION, HEIGHT, WIDTH |
| Constructor Summary | |
|---|---|
ImageIngester()
|
|
| Method Summary | |
|---|---|
void |
clear()
Clears the ingester to handle a new media stream. |
int |
getBitsPerPixel()
If ingest() was successful, returns the image's number of bits per pixel. |
String |
getComment(int index)
Returns the index'th comment retrieved from the image. |
int |
getFormat()
If ingest() was successful, returns the image format as one
of the FORMAT_xyz constants from this class. |
String |
getFormatName()
If ingest() was successful, returns the image format's name. |
int |
getHeight()
If ingest() was successful, returns one the image's vertical
resolution in pixels. |
Map<String,Object> |
getMetaData()
Provides the meta-data associated with the last ingested media asset. |
MimeType |
getMimeType()
If ingest() was successful, returns a String with the
MIME type of the format. |
int |
getNumberOfComments()
If ingest() was successful and setCollectComments(boolean) was called with
true as argument, returns the number of comments retrieved
from the input image stream / file. |
int |
getNumberOfImages()
Returns the number of images in the examined file. |
int |
getPhysicalHeightDpi()
Returns the physical height of this image in dots per inch (dpi). |
float |
getPhysicalHeightInch()
If ingest() was successful, returns the physical width of this image in dpi (dots per inch)
or -1 if no value could be found. |
int |
getPhysicalWidthDpi()
If ingest() was successful, returns the physical width of this image in dpi (dots per inch)
or -1 if no value could be found. |
float |
getPhysicalWidthInch()
Returns the physical width of an image in inches, or -1.0f if width information is not available. |
long |
getSize()
If the ingest process requires multiple passes in order to determine file size, this method should return -1 to allow the requesting application to determine size on its own. |
int |
getWidth()
If ingest() was successful, returns one the image's horizontal
resolution in pixels. |
void |
ingest()
Call this method after you have provided an input stream or file using setInput(InputStream) or setInput(DataInput). |
boolean |
isProgressive()
Returns whether the image is stored in a progressive (also called: interlaced) way. |
static void |
main(String[] args)
|
void |
setCollectComments(boolean newValue)
Specify whether textual comments are supposed to be extracted from input. |
void |
setDetermineImageNumber(boolean newValue)
Specify whether the number of images in a file is to be determined - default is false. |
void |
setInput(DataInput dataInput)
Set the input stream to the argument stream (or file). |
void |
setInput(InputStream inputStream)
Set the input stream to the argument stream (or file). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int FORMAT_JPEG
getFormat() for JPEG streams.
ImageIngester can extract physical resolution and comments
from JPEGs (only from APP0 headers).
Only one image can be stored in a file.
It is determined whether the JPEG stream is progressive
(see isProgressive()).
public static final int FORMAT_GIF
getFormat() for GIF streams.
ImageIngester can extract comments from GIFs and count the number
of images (GIFs with more than one image are animations).
If you know of a place where GIFs store the physical resolution
of an image, please
send me a
mail!
It is determined whether the GIF stream is interlaced
(see isProgressive()).
public static final int FORMAT_PNG
getFormat() for PNG streams.
PNG only supports one image per file.
Both physical resolution and comments can be stored with PNG,
but ImageIngester is currently not able to extract those.
It is determined whether the PNG stream is interlaced
(see isProgressive()).
public static final int FORMAT_BMP
getFormat() for BMP streams.
BMP only supports one image per file.
BMP does not allow for comments.
The physical resolution can be stored.
public static final int FORMAT_PCX
getFormat() for PCX streams.
PCX does not allow for comments or more than one image per file.
However, the physical resolution can be stored.
public static final int FORMAT_IFF
getFormat() for IFF streams.
public static final int FORMAT_RAS
getFormat() for RAS streams.
Sun Raster allows for one image per file only and is not able to
store physical resolution or comments.
public static final int FORMAT_PBM
getFormat() for PBM streams.
public static final int FORMAT_PGM
getFormat() for PGM streams.
public static final int FORMAT_PPM
getFormat() for PPM streams.
public static final int FORMAT_PSD
getFormat() for PSD streams.
public static final int FORMAT_SWF
getFormat() for SWF (Shockwave) streams.
public static final int COLOR_TYPE_UNKNOWN
public static final int COLOR_TYPE_TRUECOLOR_RGB
public static final int COLOR_TYPE_PALETTED
public static final int COLOR_TYPE_GRAYSCALE
public static final int COLOR_TYPE_BLACK_AND_WHITE
| Constructor Detail |
|---|
public ImageIngester()
| Method Detail |
|---|
public void clear()
Ingester
clear in interface Ingester
public void ingest()
throws InvalidMediaTypeException,
IOException
setInput(InputStream) or setInput(DataInput).
If true is returned, the file format was known and information
on the file's content can be retrieved using the various getXyz methods.
ingest in interface IngesterInvalidMediaTypeException - the media in the input stream
is not one supported by this ingester
IOException - an error occurred reading the input streampublic int getBitsPerPixel()
ingest() was successful, returns the image's number of bits per pixel.
Does not include transparency information like the alpha channel.
public String getComment(int index)
IllegalArgumentException - if index is smaller than 0 or larger than or equal
to the number of comments retrievedgetNumberOfComments()public int getFormat()
ingest() was successful, returns the image format as one
of the FORMAT_xyz constants from this class.
Use getFormatName() to get a textual description of the file format.
public String getFormatName()
ingest() was successful, returns the image format's name.
Use getFormat() to get a unique number.
public int getHeight()
ingest() was successful, returns one the image's vertical
resolution in pixels.
public Map<String,Object> getMetaData()
Ingester
getMetaData in interface Ingesterpublic MimeType getMimeType()
ingest() was successful, returns a String with the
MIME type of the format.
getMimeType in interface Ingesterimage/jpegpublic int getNumberOfComments()
ingest() was successful and setCollectComments(boolean) was called with
true as argument, returns the number of comments retrieved
from the input image stream / file.
Any number >= 0 and smaller than this number of comments is then a
valid argument for the getComment(int) method.
public int getNumberOfImages()
setDetermineImageNumber(true); was called before
a successful call to ingest().
This value can currently be only different from 1 for GIF images.
public int getPhysicalHeightDpi()
ingest() was successful.
Returns -1 on failure.
getPhysicalWidthDpi(),
getPhysicalHeightInch()public float getPhysicalHeightInch()
ingest() was successful, returns the physical width of this image in dpi (dots per inch)
or -1 if no value could be found.
getPhysicalHeightDpi(),
getPhysicalWidthDpi(),
getPhysicalWidthInch()public int getPhysicalWidthDpi()
ingest() was successful, returns the physical width of this image in dpi (dots per inch)
or -1 if no value could be found.
getPhysicalHeightDpi(),
getPhysicalWidthInch(),
getPhysicalHeightInch()public float getPhysicalWidthInch()
-1.0f if width information is not available.
Assumes that check has been called successfully.
-1.0f on failuregetPhysicalWidthDpi(),
getPhysicalHeightInch()public long getSize()
Ingester
getSize in interface Ingesterpublic int getWidth()
ingest() was successful, returns one the image's horizontal
resolution in pixels.
public boolean isProgressive()
public void setCollectComments(boolean newValue)
false.
If enabled, comments will be added to an internal list.
newValue - if true, this class will read commentsgetNumberOfComments(),
getComment(int)public void setDetermineImageNumber(boolean newValue)
false.
This is a special option because some file formats require running over
the entire file to find out the number of images, a rather time-consuming
task.
Not all file formats support more than one image.
If this method is called with true as argument,
the actual number of images can be queried via
getNumberOfImages() after a successful call to
ingest().
newValue - will the number of images be determined?getNumberOfImages()public void setInput(DataInput dataInput)
RandomAccessFile implements
DataInput.
dataInput - the input stream to read frompublic void setInput(InputStream inputStream)
setInput in interface IngesterinputStream - the input stream to read frompublic static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||