Class EXIFReader

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

public class EXIFReader extends Object
Reads EXIF and MP metadata from a JPEG, MPO or AVI file.

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

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

Author:
Werner Randelshofer
  • Constructor Details

  • Method Details

    • 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 IOException
      Reads the meta data from the file or input stream that has been set on the constructor.
      Throws:
      IOException
    • readAVIstrdChunk

      public void readAVIstrdChunk(byte[] data) throws IOException
      Reads the Exif metadata from an AVI RIFF file.
      Throws:
      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 ArrayList<TIFFDirectory> getDirectories(int image, TagSet tagSet)
      Returns all IFDDirectories of the specified tag set for the given image.
    • getThumbnails

      public ArrayList<BufferedImage> getThumbnails(boolean suppressException) throws IOException
      Returns all thumbnails.
      Throws:
      IOException
    • getMetaDataMap

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

      public IIOMetadataNode getIIOMetadataTree(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 IIOMetadata getIIOMetadata(int i)