it.geosolutions.imageio.plugins.exif
Class EXIFUtilities

Object
  extended by EXIFUtilities

public class EXIFUtilities
extends Object

Author:
Daniele Romagnoli, GeoSolutions SAS Utility class providing methods to setup/parse EXIF, write it to stream, retrieve from stream.

Nested Class Summary
static class EXIFUtilities.EXIFTagType
          Deprecated. use EXIFTags#Type
 
Field Summary
static int TAG_COPYRIGHT
          Deprecated. use EXIFTags.COPYRIGHT
static int TAG_EXIF_IFD_POINTER
          Deprecated. use EXIFTags.EXIF_IFD_POINTER
static int TAG_USER_COMMENT
          Deprecated. use EXIFTags.USER_COMMENT
 
Constructor Summary
EXIFUtilities()
           
 
Method Summary
static int bytes2ToInt(byte[] buff, int start, boolean isBigEndian)
          Simple utility methods returning an int built on top of 2 bytes, in compliance with the specified endianness
static int bytes4ToInt(byte[] buff, int start, boolean isBigEndian)
          Simple utility methods returning an int built on top of 4 bytes, in compliance with the specified endianness
static TIFFTagWrapper createTag(int tagNumber)
           
static void insertEXIFintoStream(OutputStream outputStream, byte[] imageData, int imageDataSize, EXIFMetadata exif)
          This method allows to parse the provided EXIFMetadata object and put it into the specified outputStream while copying back the JPEG encoded image referred by the imageData argument.
static byte[] intToBytes(int value)
          Simple utility method returning a 2 bytes representation of a value as bigEndian
static byte[] intToBytes(int value, boolean isBigEndian)
          Simple utility method returning a 2 bytes representation of a value, in compliance with the specified endianness
static int locateFirst(byte[] buffer, byte[] candidate)
          Scan the input byte buffer, looking for a candidate bytes sequence and return the index of the first occurrence within the input buffer, or -1 in case nothing is found.
static void replaceEXIFs(FileImageInputStreamExt inputStream, EXIFMetadata exif)
          Replace the EXIF contained within a file referred by a FileImageInputStreamExt instance with the EXIF represented by the specified EXIFMetadata instance.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_COPYRIGHT

public static final int TAG_COPYRIGHT
Deprecated. use EXIFTags.COPYRIGHT
See Also:
Constant Field Values

TAG_EXIF_IFD_POINTER

public static final int TAG_EXIF_IFD_POINTER
Deprecated. use EXIFTags.EXIF_IFD_POINTER
See Also:
Constant Field Values

TAG_USER_COMMENT

public static final int TAG_USER_COMMENT
Deprecated. use EXIFTags.USER_COMMENT
See Also:
Constant Field Values
Constructor Detail

EXIFUtilities

public EXIFUtilities()
Method Detail

insertEXIFintoStream

public static void insertEXIFintoStream(OutputStream outputStream,
                                        byte[] imageData,
                                        int imageDataSize,
                                        EXIFMetadata exif)
                                 throws IOException
This method allows to parse the provided EXIFMetadata object and put it into the specified outputStream while copying back the JPEG encoded image referred by the imageData argument.

Parameters:
outputStream - the stream where to write
imageData - the bytes containing JPEG encoded image data
imageDataSize - the number of bytes to be used from the data array
exif - the EXIFMetadata object holding EXIF.
Throws:
IOException

intToBytes

public static final byte[] intToBytes(int value,
                                      boolean isBigEndian)
Simple utility method returning a 2 bytes representation of a value, in compliance with the specified endianness

Parameters:
value - the value to be represented through 2 bytes
isBigEndian - true in case of bigEndian
Returns:

intToBytes

public static final byte[] intToBytes(int value)
Simple utility method returning a 2 bytes representation of a value as bigEndian

Parameters:
value - the value to be represented through 2 bytes
Returns:

bytes2ToInt

public static final int bytes2ToInt(byte[] buff,
                                    int start,
                                    boolean isBigEndian)
Simple utility methods returning an int built on top of 2 bytes, in compliance with the specified endianness

Parameters:
buff - the buffer containing 2 bytes to be transformed
start - the position within the buffer of the first byte to be transformed
isBigEndian - true in case we need to encode it as bigEndian
Returns:

bytes4ToInt

public static final int bytes4ToInt(byte[] buff,
                                    int start,
                                    boolean isBigEndian)
Simple utility methods returning an int built on top of 4 bytes, in compliance with the specified endianness

Parameters:
buff - the buffer containing 4 bytes to be transformed
start - the position within the buffer of the first byte to be transformed
isBigEndian - true in case we need to encode it as bigEndian
Returns:

locateFirst

public static int locateFirst(byte[] buffer,
                              byte[] candidate)
Scan the input byte buffer, looking for a candidate bytes sequence and return the index of the first occurrence within the input buffer, or -1 in case nothing is found.


replaceEXIFs

public static void replaceEXIFs(FileImageInputStreamExt inputStream,
                                EXIFMetadata exif)
                         throws IOException
Replace the EXIF contained within a file referred by a FileImageInputStreamExt instance with the EXIF represented by the specified EXIFMetadata instance. The original file will be overwritten by the new one containing updated EXIF. It is worth to point out that this replacing method won't currently perform any fields delete, but simply content update. Therefore, tags in the original EXIF which are missing in the updated EXIF parameter, won't be modified.

Parameters:
inputStream - a FileImageInputStreamExt referring to a JPEG containing EXIF
exif - the EXIFMetadata instance containing tags to be updated
Throws:
IOException

createTag

public static TIFFTagWrapper createTag(int tagNumber)
Parameters:
tagNumber -
Returns:


Copyright © 2006-2013 GeoSolutions. All Rights Reserved.