Copyright 2012-04-26 Werner Randelshofer

org.monte.media.exif
Class EXIFReader

java.lang.Object
  extended by org.monte.media.exif.EXIFReader

public class EXIFReader
extends java.lang.Object

Reads EXIF and MP meta data from a JPEG, MPO or AVI file.

Creates a tree structure of DefaultMutableTreeNodes. Nodes with a String user object describe the hierarchy of the meta data. Nodes with an MetaDataEntry as user object hold the actual meta data.

Sources:

Exchangeable image file format for digital still cameras: EXIF Version 2.2. (April, 2002). Standard of Japan Electronics and Information Technology Industries Association. JEITA CP-3451. http://www.exif.org/Exif2-2.PDF

Multi-Picture Format (February 4, 2009). Standard of the Camera & Imaging Products Association. CIPA DC-007-Translation-2009. http://www.cipa.jp/english/hyoujunka/kikaku/pdf/DC-007_E.pdf

Version:
$Id: EXIFReader.java 159 2012-01-28 17:06:34Z werner $
Author:
Werner Randelshofer

Constructor Summary
EXIFReader(java.io.File f)
           
EXIFReader(javax.imageio.stream.ImageInputStream iin)
           
 
Method Summary
 java.util.ArrayList<TIFFDirectory> getDirectories(int image, TagSet tagSet)
          Returns all IFDDirectories of the specified tag set for the given image.
 javax.imageio.metadata.IIOMetadata getIIOMetadata(int i)
           
 javax.imageio.metadata.IIOMetadataNode getIIOMetadataTree(java.lang.String formatName, int imageIndex)
          Gets the metadata as an ImageIO structure.
 int getImageCount()
          Returns the number of images that are described with EXIF.
 java.util.HashMap<TIFFTag,TIFFField> getMetaDataMap()
          Returns a flat hash map of the metadata.
 TIFFNode getMetaDataTree()
          Gets the meta data as a Swing TreeNode structure.
 java.util.ArrayList<java.awt.image.BufferedImage> getThumbnails(boolean suppressException)
          Returns all thumbnails.
 boolean isFirstImageOnly()
           
 boolean isIncludeContainerMetadata()
           
 void read()
          Reads the meta data from the file or input stream that has been set on the constructor.
 void readAVIstrdChunk(byte[] data)
          Reads the Exif metadata from an AVI RIFF file.
 void setFirstImageOnly(boolean b)
           
 void setIncludeContainerMetadata(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EXIFReader

public EXIFReader(java.io.File f)

EXIFReader

public EXIFReader(javax.imageio.stream.ImageInputStream iin)
Method Detail

setFirstImageOnly

public void setFirstImageOnly(boolean b)

isFirstImageOnly

public boolean isFirstImageOnly()

setIncludeContainerMetadata

public void setIncludeContainerMetadata(boolean b)

isIncludeContainerMetadata

public boolean isIncludeContainerMetadata()

read

public void read()
          throws java.io.IOException
Reads the meta data from the file or input stream that has been set on the constructor.

Throws:
java.io.IOException

readAVIstrdChunk

public void readAVIstrdChunk(byte[] data)
                      throws java.io.IOException
Reads the Exif metadata from an AVI RIFF file.

Throws:
java.io.IOException

getMetaDataTree

public TIFFNode getMetaDataTree()
Gets the meta data as a Swing TreeNode structure.


getImageCount

public int getImageCount()
Returns the number of images that are described with EXIF. Returns -1 if not known.


getDirectories

public java.util.ArrayList<TIFFDirectory> getDirectories(int image,
                                                         TagSet tagSet)
Returns all IFDDirectories of the specified tag set for the given image.


getThumbnails

public java.util.ArrayList<java.awt.image.BufferedImage> getThumbnails(boolean suppressException)
                                                                throws java.io.IOException
Returns all thumbnails.

Throws:
java.io.IOException

getMetaDataMap

public java.util.HashMap<TIFFTag,TIFFField> getMetaDataMap()
Returns a flat hash map of the metadata.


getIIOMetadataTree

public javax.imageio.metadata.IIOMetadataNode getIIOMetadataTree(java.lang.String formatName,
                                                                 int imageIndex)
Gets the metadata as an ImageIO structure.

Format description replicated from http://download.java.net/media/jai-imageio/javadoc/1.1/com/sun/media/imageio/plugins/tiff/package-summary.html:

The DTD for the native image metadata format is as follows:

 The DTD for the native image metadata format is as follows:
 <!DOCTYPE "com_sun_media_imageio_plugins_tiff_image_1.0" [

  <!ELEMENT "com_sun_media_imageio_plugins_tiff_image_1.0" (TIFFIFD)*>

    <!ELEMENT "TIFFIFD" (TIFFField | TIFFIFD)*>
      <!-- An IFD (directory) containing fields --> 
      <!ATTLIST "TIFFIFD" "tagSets" #CDATA #REQUIRED>
        <!-- Data type: String -->
      <!ATTLIST "TIFFIFD" "parentTagNumber" #CDATA #IMPLIED>
        <!-- The tag number of the field pointing to this IFD --> 
        <!-- Data type: Integer -->
      <!ATTLIST "TIFFIFD" "parentTagName" #CDATA #IMPLIED>
        <!-- A mnemonic name for the field pointing to this IFD, if known 
             --> 
        <!-- Data type: String -->

      <!ELEMENT "TIFFField" (TIFFBytes | TIFFAsciis |
        TIFFShorts | TIFFSShorts | TIFFLongs | TIFFSLongs |
        TIFFRationals | TIFFSRationals |
        TIFFFloats | TIFFDoubles | TIFFUndefined)>
        <!-- A field containing data --> 
        <!ATTLIST "TIFFField" "number" #CDATA #REQUIRED>
          <!-- The tag number asociated with the field --> 
          <!-- Data type: String -->
        <!ATTLIST "TIFFField" "name" #CDATA #IMPLIED>
          <!-- A mnemonic name associated with the field, if known --> 
          <!-- Data type: String -->

        <!ELEMENT "TIFFBytes" (TIFFByte)*>
          <!-- A sequence of TIFFByte nodes --> 

          <!ELEMENT "TIFFByte" EMPTY>
            <!-- An integral value between 0 and 255 --> 
            <!ATTLIST "TIFFByte" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->
            <!ATTLIST "TIFFByte" "description" #CDATA #IMPLIED>
              <!-- A description, if available --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFAsciis" (TIFFAscii)*>
          <!-- A sequence of TIFFAscii nodes --> 

          <!ELEMENT "TIFFAscii" EMPTY>
            <!-- A String value --> 
            <!ATTLIST "TIFFAscii" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFShorts" (TIFFShort)*>
          <!-- A sequence of TIFFShort nodes --> 

          <!ELEMENT "TIFFShort" EMPTY>
            <!-- An integral value between 0 and 65535 --> 
            <!ATTLIST "TIFFShort" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->
            <!ATTLIST "TIFFShort" "description" #CDATA #IMPLIED>
              <!-- A description, if available --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFSShorts" (TIFFSShort)*>
          <!-- A sequence of TIFFSShort nodes --> 

          <!ELEMENT "TIFFSShort" EMPTY>
            <!-- An integral value between -32768 and 32767 --> 
            <!ATTLIST "TIFFSShort" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->
            <!ATTLIST "TIFFSShort" "description" #CDATA #IMPLIED>
              <!-- A description, if available --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFLongs" (TIFFLong)*>
          <!-- A sequence of TIFFLong nodes --> 

          <!ELEMENT "TIFFLong" EMPTY>
            <!-- An integral value between 0 and 4294967295 --> 
            <!ATTLIST "TIFFLong" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->
            <!ATTLIST "TIFFLong" "description" #CDATA #IMPLIED>
              <!-- A description, if available --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFSLongs" (TIFFSLong)*>
          <!-- A sequence of TIFFSLong nodes --> 

          <!ELEMENT "TIFFSLong" EMPTY>
            <!-- An integral value between -2147483648 and 2147482647 --> 
            <!ATTLIST "TIFFSLong" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->
            <!ATTLIST "TIFFSLong" "description" #CDATA #IMPLIED>
              <!-- A description, if available --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFRationals" (TIFFRational)*>
          <!-- A sequence of TIFFRational nodes --> 

          <!ELEMENT "TIFFRational" EMPTY>
            <!-- A rational value consisting of an unsigned numerator and 
                 denominator --> 
            <!ATTLIST "TIFFRational" "value" #CDATA #IMPLIED>
              <!-- The numerator and denominator, separated by a slash --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFSRationals" (TIFFSRational)*>
          <!-- A sequence of TIFFSRational nodes --> 

          <!ELEMENT "TIFFSRational" EMPTY>
            <!-- A rational value consisting of a signed numerator and 
                 denominator --> 
            <!ATTLIST "TIFFSRational" "value" #CDATA #IMPLIED>
              <!-- The numerator and denominator, separated by a slash --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFFloats" (TIFFFloat)*>
          <!-- A sequence of TIFFFloat nodes --> 

          <!ELEMENT "TIFFFloat" EMPTY>
            <!-- A single-precision floating-point value --> 
            <!ATTLIST "TIFFFloat" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFDoubles" (TIFFDouble)*>
          <!-- A sequence of TIFFDouble nodes --> 

          <!ELEMENT "TIFFDouble" EMPTY>
            <!-- A double-precision floating-point value --> 
            <!ATTLIST "TIFFDouble" "value" #CDATA #IMPLIED>
              <!-- The value --> 
              <!-- Data type: String -->

        <!ELEMENT "TIFFUndefined" EMPTY>
          <!-- Uninterpreted byte data --> 
          <!ATTLIST "TIFFUndefined" "value" #CDATA #IMPLIED>
            <!-- A list of comma-separated byte values --> 
            <!-- Data type: String -->
]>
 


getIIOMetadata

public javax.imageio.metadata.IIOMetadata getIIOMetadata(int i)

Copyright 2012-04-26 Werner Randelshofer