mediautil.image.jpeg
Class AbstractImageInfo<F extends LLJTran>

java.lang.Object
  extended by mediautil.gen.BasicIo
      extended by mediautil.image.jpeg.BasicJpegIo
          extended by mediautil.image.jpeg.AbstractImageInfo<F>
All Implemented Interfaces:
Serializable, MediaInfo
Direct Known Subclasses:
CIFF, Exif, Flashpix, JFXX, JPEG

public abstract class AbstractImageInfo<F extends LLJTran>
extends BasicJpegIo
implements MediaInfo

This class represent additional information about image, such information usually supplied with an image in additional headers. Currently only Exif among derived classes provides the full capability to view and modify the Thumbnail and to modify Image Header Information through the methods writeInfo, getThumbnailOffset and getThumbnailLength. To provide more common solution, this calss has to extend javax.imageio.metadata.IIOMetadata

See Also:
Serialized Form

Field Summary
static double[] AV_TO_FSTOP
           
static byte[] BMP_SIG
           
static int BMP24_HDR_SIZE
           
static DateFormat dateformat
           
static Dimension DEFAULT_THUMB_SIZE
          Default Thumbnail Size
static DecimalFormat fnumberformat
           
static String NA
           
static Rational[] TV_TO_SEC
           
 
Fields inherited from class mediautil.image.jpeg.BasicJpegIo
M_DHP, M_DHT, M_DNL, M_DQT, M_DRI, M_EXP
 
Fields inherited from class mediautil.gen.BasicIo
FACTOR_ABVS
 
Fields inherited from interface mediautil.gen.MediaInfo
ALBUM, APERTURE, ARTIST, ARTISTWEBPAGE, AUDIOFILEWEBPAGE, AUDIOSOURCEWEBPAGE, BAND, BITRATE, BPM, CDIDENTIFIER, CLASS_AUDIO, CLASS_IMAGE, CLASS_VIDEO, COMMENTS, COMMERCIAL, COMMERCIALINFORMATION, COMPILATION, COMPOSER, CONDUCTOR, CONTENTGROUP, COPYRIGHT, COPYRIGHTTEXT, COPYRIGHTWEBPAGE, DATE, DATETIMEORIGINAL, DATETIMEORIGINALSTRING, EMPHASIS, ENCAPSULATEDOBJECT, ENCODEDBY, ENCRYPTIONMETHODREGISTRATION, EQUALISATION, ESS_CHARACHTER, ESS_MAKE, ESS_QUALITY, ESS_TIMESTAMP, EVENTTIMINGCODES, EXPOPROGRAM, FILEOWNER, FILESIZE, FILETYPE, FLASH, FNUMBER, FOCALLENGTH, FORMAT, GENRE, GROUPIDENTIFICATIONREGISTRATION, INITIALKEY, INTERNETRADIOSTATIONNAME, INTERNETRADIOSTATIONOWNER, INTERNETRADIOSTATIONWEBPAGE, ISRC, LANGUAGE, LASTMODIFIED, LASTPLAY, LAYER, LENGTH, LENGTHINTAG, LOOKUPTABLE, LYRICIST, MAKE, MEDIA_ATTRIBUTES, MEDIATYPE, METERING, MODE, MODEL, MPEGLEVEL, OFTRACKS, ORIENTATION, ORIGINAL, ORIGINALARTIST, ORIGINALFILENAME, ORIGINALLYRICIST, ORIGINALTITLE, ORIGINALYEAR, OWNERSHIP, PARTOFSET, PAYMENTWEBPAGE, PICTURE, PICTURE_ATTRIBUTES, PLAY_ATTRIBUTES, PLAYCOUNTER, PLAYLISTDELAY, POPULARIMETER, PRIVATE, PRIVATEDATA, PROTECTION, PUBLISHER, PUBLISHERSWEBPAGE, QUALITY, RATING, RECORDINGDATES, RELATIVEVOLUMENADJUSTMENT, REMIXER, RESOLUTIONX, RESOLUTIONY, REVERB, SAMPLERATE, SHUTTER, SUBTITLE, TERMSOFUSE, THUMBNAIL, TIME, TITLE, TRACK, UNIQUEFILEIDENTIFIER, USERDEFINEDTEXT, VBR, YEAR
 
Constructor Summary
AbstractImageInfo()
           
AbstractImageInfo(InputStream is, byte[] data, int offset, String name, String comments, F format)
          Loads the ImageInfo using information supplied.
 
Method Summary
 float apertureToFnumber(float aperture)
           
 AdvancedImage getAdvancedImage()
           
 Object getAttribute(String name)
           
 boolean getBoolAttribute(String name)
           
 String getComments()
           
abstract  String getDataTimeOriginalString()
           
 Date getDateTimeOriginal()
           
 double getDoubleAttribute(String name)
           
abstract  int getExpoProgram()
           
 Object[] getFiveMajorAttributes()
          returns for format such attributes as: title, artist, album, year, file
 float getFloatAttribute(String name)
           
abstract  float getFNumber()
           
abstract  float getFocalLength()
           
abstract  String getFormat()
           
 File getImageFile()
           
 int getIntAttribute(String name)
           
 long getLongAttribute(String name)
           
abstract  String getMake()
           
abstract  int getMetering()
           
abstract  String getModel()
           
 String getName()
           
abstract  String getQuality()
           
abstract  String getReport()
           
abstract  int getResolutionX()
           
abstract  int getResolutionY()
           
abstract  Rational getShutter()
           
 String getThumbnailExtension()
          Gets the extension of the Thumbnail Image format.
 Icon getThumbnailIcon()
           
abstract  Icon getThumbnailIcon(Dimension size)
           
 int getThumbnailLength()
          Method to get the length of the Thumbnail.
 int getThumbnailOffset()
          Method to get the offset of the Thumbnail within the imageInfo data.
abstract  boolean isFlash()
           
abstract  void readInfo()
          Reads the imageInfo from the Input supplied in Constructor.
 boolean removeThumbnailTags()
          Removes the Thumbnail Tags in the imageInfo.
 boolean saveThumbnailImage(OutputStream os)
          saves thumbnail image to specified path
 void setAdvancedImage(AdvancedImage advancedImage)
           
 void setAttribute(String name, Object value)
           
 void setName(String name)
           
 void setThumbnail(byte[] newThumbnailData, int startIndex, int len, String thumbnailExt, OutputStream newAppHdrOp)
          Method to write the imageInfo with a new Thumbnail.
 String toString()
           
 void writeInfo(byte[] markerData, OutputStream out, int op, int options, boolean modifyImageInfo)
          writeInfo method without actual imageWidth and imageHeight
 void writeInfo(byte[] markerData, OutputStream out, int op, int options, boolean modifyImageInfo, int imageWidth, int imageHeight)
          writeInfo method using default encoding of ISO8859_1
 void writeInfo(byte[] markerData, OutputStream out, int op, int options, boolean modifyImageInfo, int imageWidth, int imageHeight, String encoding)
          Writes modified or not Exif to out.
 
Methods inherited from class mediautil.gen.BasicIo
asInt, asString, bn2s, bn2s, convertLength, in2s, isSignature, read, read, s2n, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_THUMB_SIZE

public static final Dimension DEFAULT_THUMB_SIZE
Default Thumbnail Size


dateformat

public static final DateFormat dateformat

fnumberformat

public static final DecimalFormat fnumberformat

NA

public static final String NA
See Also:
Constant Field Values

BMP_SIG

public static final byte[] BMP_SIG

BMP24_HDR_SIZE

public static final int BMP24_HDR_SIZE
See Also:
Constant Field Values

AV_TO_FSTOP

public static final double[] AV_TO_FSTOP

TV_TO_SEC

public static final Rational[] TV_TO_SEC
Constructor Detail

AbstractImageInfo

public AbstractImageInfo()

AbstractImageInfo

public AbstractImageInfo(InputStream is,
                         byte[] data,
                         int offset,
                         String name,
                         String comments,
                         F format)
                  throws FileFormatException
Loads the ImageInfo using information supplied. Relies on the implementation of readInfo() by the deriving class.

Parameters:
is - Image input. Note that LLJTran does not pass the actual ImageInput but only the Marker Data. This is because LLJTran will have to read further from the same Input Stream.
data - Image Header Information Marker Data excluding the 4 jpeg marker bytes
offset - Offset of marker within Image Input
name - Name of the Image File
comments - Image comments
format - Image Object of type LLJTran
Throws:
FileFormatException
Method Detail

getName

public String getName()

setName

public void setName(String name)

setAdvancedImage

public void setAdvancedImage(AdvancedImage advancedImage)

getAdvancedImage

public AdvancedImage getAdvancedImage()

writeInfo

public void writeInfo(byte[] markerData,
                      OutputStream out,
                      int op,
                      int options,
                      boolean modifyImageInfo)
               throws IOException
writeInfo method without actual imageWidth and imageHeight

Throws:
IOException
See Also:
writeInfo(byte[],OutputStream,int,int,boolean,int,int,String)

writeInfo

public void writeInfo(byte[] markerData,
                      OutputStream out,
                      int op,
                      int options,
                      boolean modifyImageInfo,
                      int imageWidth,
                      int imageHeight)
               throws IOException
writeInfo method using default encoding of ISO8859_1

Throws:
IOException
See Also:
writeInfo(byte[],OutputStream,int,int,boolean,int,int,String)

writeInfo

public void writeInfo(byte[] markerData,
                      OutputStream out,
                      int op,
                      int options,
                      boolean modifyImageInfo,
                      int imageWidth,
                      int imageHeight,
                      String encoding)
               throws IOException
Writes modified or not Exif to out. APP header and its length are not included so any wrapper should do that calculation.

This method is mainly for use by LLJTran to regenerate the Appx marker Data for the imageInfo. The default implementation does nothing and is expected to be implemented by the deriving class.

Parameters:
markerData - The existing markerData
out - Output Stream to write out the new markerData
op - The transformation option. This is used to switch the width and height in imageInfo if op is a ROT_90 like transform and transform the orientation tag and Thumbnail if opted for.
options - OPT_XFORM_.. options of LLJTran. LLJTran passes its options directly to this method. This uses the imageInfo related flags LLJTran.OPT_XFORM_THUMBNAIL and LLJTran.OPT_XFORM_ORIENTATION and makes the necessary changes to imageInfo depending on the transform specified by op before writing.
modifyImageInfo - If true the changes made to imageInfo are retained, otherwise the state is restored at the end of the call.
imageWidth - Actual Image Width. If this and imageHeight are positive then they are used for the width and height in imageInfo and no switching of width and height is done for ROT_90 like transforms.
imageHeight - Actaul Image Height
encoding - Encoding to be used when for writing out Character information like comments.
Throws:
IOException

readInfo

public abstract void readInfo()
                       throws FileFormatException
Reads the imageInfo from the Input supplied in Constructor. This is for derived class to implement.

Throws:
FileFormatException

getFormat

public abstract String getFormat()

getResolutionX

public abstract int getResolutionX()

getResolutionY

public abstract int getResolutionY()

getMake

public abstract String getMake()

getModel

public abstract String getModel()

getDataTimeOriginalString

public abstract String getDataTimeOriginalString()

getFNumber

public abstract float getFNumber()

getShutter

public abstract Rational getShutter()

isFlash

public abstract boolean isFlash()

getQuality

public abstract String getQuality()

getFocalLength

public abstract float getFocalLength()

getMetering

public abstract int getMetering()

getExpoProgram

public abstract int getExpoProgram()

getReport

public abstract String getReport()

getThumbnailOffset

public int getThumbnailOffset()
Method to get the offset of the Thumbnail within the imageInfo data.

The default implementation returns -1 since this method is expected to be implemented by the deriving class.

Returns:
Offset of the Thumbnail within the Appx marker data

getThumbnailLength

public int getThumbnailLength()
Method to get the length of the Thumbnail.

The default implementation returns -1 since this method is expected to be implemented by the deriving class.

Returns:
Length of the Thumbnail

setThumbnail

public void setThumbnail(byte[] newThumbnailData,
                         int startIndex,
                         int len,
                         String thumbnailExt,
                         OutputStream newAppHdrOp)
                  throws IOException
Method to write the imageInfo with a new Thumbnail.

This method changes the imageInfo for the new Thumbnail and writes out the corresponding Appx header data (without jpeg markers) with the new Thumbnail.

The default implementation does nothing since this method is expected to be implemented by the deriving class.

Parameters:
newThumbnailData - New Thumbnail image data
startIndex - Offset within newThumbnailData where the image starts
len - Length of Thumbnail Image
thumbnailExt - Extension of the Thumbnail Image from ImageResources which identifies the format of the Thumbnail image.
newAppHdrOp - Output to write out the new Appx data
Throws:
IOException

removeThumbnailTags

public boolean removeThumbnailTags()
Removes the Thumbnail Tags in the imageInfo. Thus the next time the Appx is written using writeInfo(..) it will be without a Thumbnail.

Returns:
True if successful. False if failed or if the feature is not supported. Since this method should be implemented by Subclasses the default implementation just returns false.

getThumbnailIcon

public abstract Icon getThumbnailIcon(Dimension size)

toString

public String toString()
Overrides:
toString in class Object

getFiveMajorAttributes

public Object[] getFiveMajorAttributes()
returns for format such attributes as: title, artist, album, year, file

Specified by:
getFiveMajorAttributes in interface MediaInfo

getThumbnailIcon

public Icon getThumbnailIcon()

getThumbnailExtension

public String getThumbnailExtension()
Gets the extension of the Thumbnail Image format. Returns null if the image has no Thumbnail.

Returns:
Thumbnail Extension as defined in ImageResources. The default implementation returns ImageResources.EXT_JPEG to indicate JPEG format.
See Also:
ImageResources

getComments

public String getComments()

getImageFile

public File getImageFile()

saveThumbnailImage

public boolean saveThumbnailImage(OutputStream os)
                           throws IOException
saves thumbnail image to specified path

Throws:
IOException

getDateTimeOriginal

public Date getDateTimeOriginal()

apertureToFnumber

public float apertureToFnumber(float aperture)

setAttribute

public void setAttribute(String name,
                         Object value)
Specified by:
setAttribute in interface MediaInfo

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface MediaInfo

getIntAttribute

public int getIntAttribute(String name)
Specified by:
getIntAttribute in interface MediaInfo

getFloatAttribute

public float getFloatAttribute(String name)
Specified by:
getFloatAttribute in interface MediaInfo

getLongAttribute

public long getLongAttribute(String name)
Specified by:
getLongAttribute in interface MediaInfo

getDoubleAttribute

public double getDoubleAttribute(String name)
Specified by:
getDoubleAttribute in interface MediaInfo

getBoolAttribute

public boolean getBoolAttribute(String name)
Specified by:
getBoolAttribute in interface MediaInfo