Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.media.exif
Class EXIFReader

java.lang.Object
  extended by ch.randelshofer.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:
1.2 2010-07-23 Added
1.1 2010-07-09 Fujifilm Makernote stores data with relative offsets to IFD. Added support for AVI RIFF files.
1.0 2009-12-27 Created.
Author:
Werner Randelshofer

Constructor Summary
EXIFReader(java.io.File f)
           
EXIFReader(javax.imageio.stream.ImageInputStream iin)
           
 
Method Summary
 javax.imageio.metadata.IIOMetadataNode getIIOMetadataTree(java.lang.String formatName, int imageIndex)
          Gets the metadata as an ImageIO structure.
 java.util.HashMap<TIFFTag,TIFFField> getMetaDataMap()
          Returns a flat hash map of the metadata.
 TIFFNode getMetaDataTree()
          Gets the metadata as a Swing TreeNode structure.
 boolean isFirstImageOnly()
           
 void read()
           
 void setFirstImageOnly(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()

read

public void read()
          throws java.io.IOException
Throws:
java.io.IOException

getMetaDataTree

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


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 -->
]>
 


Copyright 2011-01-06 Werner Randelshofer