Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.drew.metadata.exif
Class ExifReader  view ExifReader download ExifReader.java

java.lang.Object
  extended bycom.drew.metadata.exif.ExifReader
All Implemented Interfaces:
com.drew.metadata.MetadataReader

public class ExifReader
extends java.lang.Object
implements com.drew.metadata.MetadataReader

Extracts Exif data from a JPEG header segment, providing information about the camera/scanner/capture device (if available). Information is encapsulated in an Metadata object.


Field Summary
private  byte[] _data
          The JPEG segment as an array of bytes.
private  com.drew.metadata.Metadata _metadata
          Bean instance to store information about the image and camera/scanner/capture device.
(package private) static int[] BYTES_PER_FORMAT
          The number of bytes used per format descriptor.
private static int FMT_BYTE
           
private static int FMT_DOUBLE
           
private static int FMT_SBYTE
           
private static int FMT_SINGLE
           
private static int FMT_SLONG
           
private static int FMT_SRATIONAL
           
private static int FMT_SSHORT
           
private static int FMT_STRING
           
private static int FMT_ULONG
           
private static int FMT_UNDEFINED
           
private static int FMT_URATIONAL
           
private static int FMT_USHORT
           
private static int MAX_FORMAT_CODE
          The number of formats known.
private  boolean motorollaByteOrder
          Represents the native byte ordering used in the JPEG segment.
static int TAG_EXIF_OFFSET
           
static int TAG_GPS_INFO_OFFSET
           
static int TAG_INTEROP_OFFSET
           
static int TAG_MAKER_NOTE
           
static int TIFF_HEADER_START_OFFSET
           
 
Constructor Summary
ExifReader(byte[] data)
          Creates an ExifReader for the given JPEG header segment.
ExifReader(java.io.File file)
           
 
Method Summary
private  int calculateDirectoryEntryOffset(int ifdStartOffset, int entryNumber)
          Determine the offset at which a given InteropArray entry begins within the specified IFD.
private  int calculateTagValueOffset(int byteCount, int dirEntryOffset)
           
 com.drew.metadata.Metadata extract()
          Performs the Exif data extraction, returning a new instance of Metadata.
 com.drew.metadata.Metadata extract(com.drew.metadata.Metadata metadata)
          Performs the Exif data extraction, adding found values to the specified instance of Metadata.
private  void extractThumbnail(com.drew.metadata.Directory exifDirectory)
           
private  int get16Bits(int offset)
          Get a 16 bit value from file's native byte order.
private  int get32Bits(int offset)
          Get a 32 bit value from file's native byte order.
private  boolean isDirectoryLengthValid(int dirStartOffset)
           
private  void processDirectory(com.drew.metadata.Directory directory, int dirStartOffset)
          Process one of the nested EXIF directories.
private  void processMakerNote(int subdirOffset)
           
private  void processTag(com.drew.metadata.Directory directory, int tagType, int tagValueOffset, int componentCount, int formatCode)
           
private  java.lang.String readString(int offset, int maxLength)
          Creates a String from the _data buffer starting at the specified offset, and ending where byte=='\0' or where length==maxLength.
private  boolean setByteOrder(java.lang.String byteOrderIdentifier)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_data

private byte[] _data
The JPEG segment as an array of bytes.


motorollaByteOrder

private boolean motorollaByteOrder
Represents the native byte ordering used in the JPEG segment. If true, then we're using Motorolla ordering (Big endian), else we're using Intel ordering (Little endian).


_metadata

private com.drew.metadata.Metadata _metadata
Bean instance to store information about the image and camera/scanner/capture device.


BYTES_PER_FORMAT

static final int[] BYTES_PER_FORMAT
The number of bytes used per format descriptor.


MAX_FORMAT_CODE

private static final int MAX_FORMAT_CODE
The number of formats known.

See Also:
Constant Field Values

FMT_BYTE

private static final int FMT_BYTE
See Also:
Constant Field Values

FMT_STRING

private static final int FMT_STRING
See Also:
Constant Field Values

FMT_USHORT

private static final int FMT_USHORT
See Also:
Constant Field Values

FMT_ULONG

private static final int FMT_ULONG
See Also:
Constant Field Values

FMT_URATIONAL

private static final int FMT_URATIONAL
See Also:
Constant Field Values

FMT_SBYTE

private static final int FMT_SBYTE
See Also:
Constant Field Values

FMT_UNDEFINED

private static final int FMT_UNDEFINED
See Also:
Constant Field Values

FMT_SSHORT

private static final int FMT_SSHORT
See Also:
Constant Field Values

FMT_SLONG

private static final int FMT_SLONG
See Also:
Constant Field Values

FMT_SRATIONAL

private static final int FMT_SRATIONAL
See Also:
Constant Field Values

FMT_SINGLE

private static final int FMT_SINGLE
See Also:
Constant Field Values

FMT_DOUBLE

private static final int FMT_DOUBLE
See Also:
Constant Field Values

TAG_EXIF_OFFSET

public static final int TAG_EXIF_OFFSET
See Also:
Constant Field Values

TAG_INTEROP_OFFSET

public static final int TAG_INTEROP_OFFSET
See Also:
Constant Field Values

TAG_GPS_INFO_OFFSET

public static final int TAG_GPS_INFO_OFFSET
See Also:
Constant Field Values

TAG_MAKER_NOTE

public static final int TAG_MAKER_NOTE
See Also:
Constant Field Values

TIFF_HEADER_START_OFFSET

public static final int TIFF_HEADER_START_OFFSET
See Also:
Constant Field Values
Constructor Detail

ExifReader

public ExifReader(java.io.File file)
           throws com.drew.imaging.jpeg.JpegProcessingException,
                  java.io.FileNotFoundException

ExifReader

public ExifReader(byte[] data)
Creates an ExifReader for the given JPEG header segment.

Method Detail

extract

public com.drew.metadata.Metadata extract()
Performs the Exif data extraction, returning a new instance of Metadata.

Specified by:
extract in interface com.drew.metadata.MetadataReader

extract

public com.drew.metadata.Metadata extract(com.drew.metadata.Metadata metadata)
Performs the Exif data extraction, adding found values to the specified instance of Metadata.

Specified by:
extract in interface com.drew.metadata.MetadataReader

extractThumbnail

private void extractThumbnail(com.drew.metadata.Directory exifDirectory)

setByteOrder

private boolean setByteOrder(java.lang.String byteOrderIdentifier)

processDirectory

private void processDirectory(com.drew.metadata.Directory directory,
                              int dirStartOffset)
Process one of the nested EXIF directories.


processMakerNote

private void processMakerNote(int subdirOffset)

isDirectoryLengthValid

private boolean isDirectoryLengthValid(int dirStartOffset)

processTag

private void processTag(com.drew.metadata.Directory directory,
                        int tagType,
                        int tagValueOffset,
                        int componentCount,
                        int formatCode)

calculateTagValueOffset

private int calculateTagValueOffset(int byteCount,
                                    int dirEntryOffset)

readString

private java.lang.String readString(int offset,
                                    int maxLength)
Creates a String from the _data buffer starting at the specified offset, and ending where byte=='\0' or where length==maxLength.


calculateDirectoryEntryOffset

private int calculateDirectoryEntryOffset(int ifdStartOffset,
                                          int entryNumber)
Determine the offset at which a given InteropArray entry begins within the specified IFD.


get16Bits

private int get16Bits(int offset)
Get a 16 bit value from file's native byte order. Between 0x0000 and 0xFFFF.


get32Bits

private int get32Bits(int offset)
Get a 32 bit value from file's native byte order.