|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectloci.formats.TiffTools
public final class TiffTools
A utility class for manipulating TIFF files.
Field Summary | |
---|---|
static int |
ARTIST
|
static int |
ASCII
|
static int |
BIG
|
static int |
BIG_TIFF
|
static int |
BIG_TIFF_BYTES_PER_ENTRY
The number of bytes in each IFD entry of a BigTIFF file. |
static int |
BIG_TIFF_MAGIC_NUMBER
|
static int |
BITS_PER_SAMPLE
|
static int |
BLACK_IS_ZERO
|
static int |
BYTE
|
static int[] |
BYTES_PER_ELEMENT
|
static int |
BYTES_PER_ENTRY
The number of bytes in each IFD entry. |
static int |
CCITT_1D
|
static int |
CELL_LENGTH
|
static int |
CELL_WIDTH
|
static int |
CFA_ARRAY
|
static int |
CIE_LAB
|
static int |
CMYK
|
static int |
COLOR_MAP
|
static int |
COMPRESSION
|
static int |
COPYRIGHT
|
static int |
DATE_TIME
|
static int |
DEFLATE
|
static int |
DOCUMENT_NAME
|
static int |
DOT_RANGE
|
static int |
DOUBLE
|
static int |
EXTRA_SAMPLES
|
static int |
FILL_ORDER
|
static int |
FLOAT
|
static int |
FREE_BYTE_COUNTS
|
static int |
FREE_OFFSETS
|
static int |
GRAY_RESPONSE_CURVE
|
static int |
GRAY_RESPONSE_UNIT
|
static int |
GROUP_3_FAX
|
static int |
GROUP_4_FAX
|
static int |
HALFTONE_HINTS
|
static int |
HOST_COMPUTER
|
static int |
IFD8
|
static int |
IMAGE_DESCRIPTION
|
static int |
IMAGE_LENGTH
|
static int |
IMAGE_WIDTH
|
static int |
INK_NAMES
|
static int |
INK_SET
|
static int |
JPEG
|
static int |
JPEG_AC_TABLES
|
static int |
JPEG_DC_TABLES
|
static int |
JPEG_INTERCHANGE_FORMAT
|
static int |
JPEG_INTERCHANGE_FORMAT_LENGTH
|
static int |
JPEG_LOSSLESS_PREDICTORS
|
static int |
JPEG_POINT_TRANSFORMS
|
static int |
JPEG_PROC
|
static int |
JPEG_Q_TABLES
|
static int |
JPEG_RESTART_INTERVAL
|
static int |
LITTLE
|
static int |
LITTLE_ENDIAN
|
static int |
LONG
|
static int |
LONG8
|
static int |
LURAWAVE
|
static int |
LZW
|
static int |
MAGIC_NUMBER
|
static int |
MAKE
|
static int |
MAX_SAMPLE_VALUE
|
static int |
MIN_SAMPLE_VALUE
|
static int |
MODEL
|
static int |
NEW_SUBFILE_TYPE
|
static int |
NIKON
|
static int |
NUMBER_OF_INKS
|
static int |
ORIENTATION
|
static int |
PACK_BITS
|
static int |
PAGE_NAME
|
static int |
PAGE_NUMBER
|
static int |
PHOTOMETRIC_INTERPRETATION
|
static int |
PLANAR_CONFIGURATION
|
static int |
PREDICTOR
|
static int |
PRIMARY_CHROMATICITIES
|
static int |
PROPRIETARY_DEFLATE
|
static int |
RATIONAL
|
static int |
REFERENCE_BLACK_WHITE
|
static int |
RESOLUTION_UNIT
|
static int |
RGB
|
static int |
RGB_PALETTE
|
static int |
ROWS_PER_STRIP
|
static int |
S_MAX_SAMPLE_VALUE
|
static int |
S_MIN_SAMPLE_VALUE
|
static int |
SAMPLE_FORMAT
|
static int |
SAMPLES_PER_PIXEL
|
static int |
SBYTE
|
static int |
SHORT
|
static int |
SLONG
|
static int |
SLONG8
|
static int |
SOFTWARE
|
static int |
SRATIONAL
|
static int |
SSHORT
|
static int |
STRIP_BYTE_COUNTS
|
static int |
STRIP_OFFSETS
|
static int |
SUBFILE_TYPE
|
static int |
T4_OPTIONS
|
static int |
T6_OPTIONS
|
static int |
TARGET_PRINTER
|
static int |
THRESHHOLDING
|
static int |
THUNDERSCAN
|
static int |
TILE_BYTE_COUNTS
|
static int |
TILE_LENGTH
|
static int |
TILE_OFFSETS
|
static int |
TILE_WIDTH
|
static int |
TRANSFER_FUNCTION
|
static int |
TRANSFER_RANGE
|
static int |
TRANSPARENCY_MASK
|
static int |
UNCOMPRESSED
|
static int |
UNDEFINED
|
static int |
WHITE_IS_ZERO
|
static int |
WHITE_POINT
|
static int |
X_POSITION
|
static int |
X_RESOLUTION
|
static int |
Y_CB_CR
|
static int |
Y_CB_CR_COEFFICIENTS
|
static int |
Y_CB_CR_POSITIONING
|
static int |
Y_CB_CR_SUB_SAMPLING
|
static int |
Y_POSITION
|
static int |
Y_RESOLUTION
|
Method Summary | |
---|---|
static Boolean |
checkHeader(byte[] block)
Checks the TIFF header. |
static Boolean |
checkHeader(RandomAccessStream in)
Checks the TIFF header. |
static byte[] |
compress(byte[] input,
int compression)
Encodes a strip of data with the given compression scheme. |
static void |
debug(String message)
Prints a debugging message with current time. |
static void |
difference(byte[] input,
int[] bitsPerSample,
long width,
int planarConfig,
int predictor)
Performs in-place differencing according to the given predictor value. |
static int[] |
getBitsPerSample(Hashtable ifd)
Retrieves the image's bits per sample (TIFF tag BitsPerSample) from a given TIFF IFD. |
static String |
getComment(String id)
Convenience method for obtaining a file's first ImageDescription. |
static int |
getCompression(Hashtable ifd)
Retrieves the image's compression type (TIFF tag Compression) from a given TIFF IFD. |
static String |
getFieldName(int value)
This method uses reflection to scan the values of this class's static fields, returning the first matching field's name. |
static Hashtable |
getFirstIFD(RandomAccessStream in)
Gets the first IFD within the given TIFF file, or null if the given file is not a valid TIFF file. |
static TiffIFDEntry |
getFirstIFDEntry(RandomAccessStream in,
int tag)
Retrieve a given entry from the first IFD in a stream. |
static long |
getFirstOffset(RandomAccessStream in)
Gets offset to the first IFD, or -1 if stream is not TIFF. |
static long |
getFirstOffset(RandomAccessStream in,
boolean bigTiff)
Gets offset to the first IFD, or -1 if stream is not TIFF. |
static Hashtable |
getIFD(RandomAccessStream in,
long ifdNum,
long offset)
Gets the IFD stored at the given offset. |
static Hashtable |
getIFD(RandomAccessStream in,
long ifdNum,
long offset,
boolean bigTiff)
Gets the IFD stored at the given offset. |
static int[] |
getIFDIntArray(Hashtable ifd,
int tag,
boolean checkNull)
Gets the given directory entry values in int format from the specified IFD, performing some error checking. |
static int |
getIFDIntValue(Hashtable ifd,
int tag)
Gets the given directory entry value in int format from the specified IFD, or -1 if the given directory does not exist. |
static int |
getIFDIntValue(Hashtable ifd,
int tag,
boolean checkNull,
int defaultValue)
Gets the given directory entry value in int format from the specified IFD, performing some error checking. |
static long[] |
getIFDLongArray(Hashtable ifd,
int tag,
boolean checkNull)
Gets the given directory entry values in long format from the specified IFD, performing some error checking. |
static long |
getIFDLongValue(Hashtable ifd,
int tag,
boolean checkNull,
long defaultValue)
Gets the given directory entry value in long format from the specified IFD, performing some error checking. |
static TiffRational |
getIFDRationalValue(Hashtable ifd,
int tag,
boolean checkNull)
Gets the given directory entry value in rational format from the specified IFD, performing some error checking. |
static Hashtable[] |
getIFDs(RandomAccessStream in)
Gets all IFDs within the given TIFF file, or null if the given file is not a valid TIFF file. |
static short[] |
getIFDShortArray(Hashtable ifd,
int tag,
boolean checkNull)
Gets the given directory entry values in short format from the specified IFD, performing some error checking. |
static String |
getIFDTagName(int tag)
Gets the name of the IFD tag encoded by the given number. |
static String |
getIFDTypeName(int type)
Gets the name of the IFD type encoded by the given number. |
static Object |
getIFDValue(Hashtable ifd,
int tag)
Gets the given directory entry value from the specified IFD. |
static Object |
getIFDValue(Hashtable ifd,
int tag,
boolean checkNull,
Class checkClass)
Gets the given directory entry value from the specified IFD, performing some error checking. |
static BufferedImage |
getImage(Hashtable ifd,
RandomAccessStream in)
Reads the image defined in the given IFD from the specified file. |
static long |
getImageLength(Hashtable ifd)
Retrieves the image's length (TIFF tag ImageLength) from a given TIFF IFD. |
static long |
getImageWidth(Hashtable ifd)
Retrieves the image's width (TIFF tag ImageWidth) from a given TIFF IFD. |
static int |
getPhotometricInterpretation(Hashtable ifd)
Retrieves the image's photometric interpretation (TIFF tag PhotometricInterpretation) from a given TIFF IFD. |
static long[] |
getRowsPerStrip(Hashtable ifd)
Retrieves the number of rows per strip for image (TIFF tag RowsPerStrip) from a given TIFF IFD. |
static byte[][] |
getSamples(Hashtable ifd,
RandomAccessStream in)
Reads the image defined in the given IFD from the specified file. |
static byte[] |
getSamples(Hashtable ifd,
RandomAccessStream in,
byte[] buf)
|
static int |
getSamplesPerPixel(Hashtable ifd)
Retrieves the number of samples per pixel for the image (TIFF tag SamplesPerPixel) from a given TIFF IFD. |
static long[] |
getStripByteCounts(Hashtable ifd)
Retrieves strip byte counts for the image (TIFF tag StripByteCounts) from a given TIFF IFD. |
static long[] |
getStripOffsets(Hashtable ifd)
Retrieves the strip offsets for the image (TIFF tag StripOffsets) from a given TIFF IFD. |
static boolean |
isBigTiff(Hashtable ifd)
Gets whether this is a BigTIFF IFD. |
static boolean |
isLittleEndian(Hashtable ifd)
Gets whether the TIFF information in the given IFD is little-endian. |
static boolean |
isValidHeader(byte[] block)
Tests the given data block to see if it represents the first few bytes of a TIFF file. |
static void |
overwriteComment(String id,
Object value)
Convenience method for overwriting a file's first ImageDescription. |
static void |
overwriteIFDValue(RandomAccessFile raf,
int ifd,
int tag,
Object value)
Surgically overwrites an existing IFD value with the given one. |
static void |
planarUnpack(short[][] samples,
int startIndex,
byte[] bytes,
int[] bitsPerSample,
int photoInterp,
boolean littleEndian,
int strip,
int numStrips)
Extracts pixel information from the given byte array according to the bits per sample, photometric interpretation, and the specified byte ordering. |
static void |
putIFDValue(Hashtable ifd,
int tag,
int value)
Adds a directory entry of type SHORT to an IFD. |
static void |
putIFDValue(Hashtable ifd,
int tag,
long value)
Adds a directory entry of type LONG to an IFD. |
static void |
putIFDValue(Hashtable ifd,
int tag,
Object value)
Adds a directory entry to an IFD. |
static void |
putIFDValue(Hashtable ifd,
int tag,
short value)
Adds a directory entry of type BYTE to an IFD. |
static byte[] |
uncompress(byte[] input,
int compression)
Decodes a strip of data compressed with the given compression scheme. |
static void |
undifference(byte[] input,
int[] bitsPerSample,
long width,
int planarConfig,
int predictor)
Undoes in-place differencing according to the given predictor value. |
static void |
unpackBytes(short[][] samples,
int startIndex,
byte[] bytes,
int[] bitsPerSample,
int photoInterp,
int[] colorMap,
boolean littleEndian,
long maxValue,
int planar,
int strip,
int numStrips,
long imageWidth)
Extracts pixel information from the given byte array according to the bits per sample, photometric interpretation and color map IFD directory entry values, and the specified byte ordering. |
static void |
writeIFDValue(DataOutput ifdOut,
ByteArrayOutputStream extraBuf,
DataOutputStream extraOut,
int offset,
int tag,
Object value)
Writes the given IFD value to the given output object. |
static long |
writeImage(BufferedImage img,
Hashtable ifd,
OutputStream out,
int offset,
boolean last)
Writes the given field to the specified output stream using the given byte offset and IFD, in big-endian format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BYTES_PER_ENTRY
public static final int BIG_TIFF_BYTES_PER_ENTRY
public static final int LITTLE_ENDIAN
public static final int BIG_TIFF
public static final int BYTE
public static final int ASCII
public static final int SHORT
public static final int LONG
public static final int RATIONAL
public static final int SBYTE
public static final int UNDEFINED
public static final int SSHORT
public static final int SLONG
public static final int SRATIONAL
public static final int FLOAT
public static final int DOUBLE
public static final int LONG8
public static final int SLONG8
public static final int IFD8
public static final int[] BYTES_PER_ELEMENT
public static final int NEW_SUBFILE_TYPE
public static final int SUBFILE_TYPE
public static final int IMAGE_WIDTH
public static final int IMAGE_LENGTH
public static final int BITS_PER_SAMPLE
public static final int COMPRESSION
public static final int PHOTOMETRIC_INTERPRETATION
public static final int THRESHHOLDING
public static final int CELL_WIDTH
public static final int CELL_LENGTH
public static final int FILL_ORDER
public static final int DOCUMENT_NAME
public static final int IMAGE_DESCRIPTION
public static final int MAKE
public static final int MODEL
public static final int STRIP_OFFSETS
public static final int ORIENTATION
public static final int SAMPLES_PER_PIXEL
public static final int ROWS_PER_STRIP
public static final int STRIP_BYTE_COUNTS
public static final int MIN_SAMPLE_VALUE
public static final int MAX_SAMPLE_VALUE
public static final int X_RESOLUTION
public static final int Y_RESOLUTION
public static final int PLANAR_CONFIGURATION
public static final int PAGE_NAME
public static final int X_POSITION
public static final int Y_POSITION
public static final int FREE_OFFSETS
public static final int FREE_BYTE_COUNTS
public static final int GRAY_RESPONSE_UNIT
public static final int GRAY_RESPONSE_CURVE
public static final int T4_OPTIONS
public static final int T6_OPTIONS
public static final int RESOLUTION_UNIT
public static final int PAGE_NUMBER
public static final int TRANSFER_FUNCTION
public static final int SOFTWARE
public static final int DATE_TIME
public static final int ARTIST
public static final int HOST_COMPUTER
public static final int PREDICTOR
public static final int WHITE_POINT
public static final int PRIMARY_CHROMATICITIES
public static final int COLOR_MAP
public static final int HALFTONE_HINTS
public static final int TILE_WIDTH
public static final int TILE_LENGTH
public static final int TILE_OFFSETS
public static final int TILE_BYTE_COUNTS
public static final int INK_SET
public static final int INK_NAMES
public static final int NUMBER_OF_INKS
public static final int DOT_RANGE
public static final int TARGET_PRINTER
public static final int EXTRA_SAMPLES
public static final int SAMPLE_FORMAT
public static final int S_MIN_SAMPLE_VALUE
public static final int S_MAX_SAMPLE_VALUE
public static final int TRANSFER_RANGE
public static final int JPEG_PROC
public static final int JPEG_INTERCHANGE_FORMAT
public static final int JPEG_INTERCHANGE_FORMAT_LENGTH
public static final int JPEG_RESTART_INTERVAL
public static final int JPEG_LOSSLESS_PREDICTORS
public static final int JPEG_POINT_TRANSFORMS
public static final int JPEG_Q_TABLES
public static final int JPEG_DC_TABLES
public static final int JPEG_AC_TABLES
public static final int Y_CB_CR_COEFFICIENTS
public static final int Y_CB_CR_SUB_SAMPLING
public static final int Y_CB_CR_POSITIONING
public static final int REFERENCE_BLACK_WHITE
public static final int COPYRIGHT
public static final int UNCOMPRESSED
public static final int CCITT_1D
public static final int GROUP_3_FAX
public static final int GROUP_4_FAX
public static final int LZW
public static final int JPEG
public static final int PACK_BITS
public static final int PROPRIETARY_DEFLATE
public static final int DEFLATE
public static final int THUNDERSCAN
public static final int NIKON
public static final int LURAWAVE
public static final int WHITE_IS_ZERO
public static final int BLACK_IS_ZERO
public static final int RGB
public static final int RGB_PALETTE
public static final int TRANSPARENCY_MASK
public static final int CMYK
public static final int Y_CB_CR
public static final int CIE_LAB
public static final int CFA_ARRAY
public static final int MAGIC_NUMBER
public static final int BIG_TIFF_MAGIC_NUMBER
public static final int LITTLE
public static final int BIG
Method Detail |
---|
public static boolean isValidHeader(byte[] block)
public static Boolean checkHeader(byte[] block)
public static boolean isBigTiff(Hashtable ifd) throws FormatException
FormatException
public static boolean isLittleEndian(Hashtable ifd) throws FormatException
FormatException
public static Hashtable[] getIFDs(RandomAccessStream in) throws IOException
IOException
public static Hashtable getFirstIFD(RandomAccessStream in) throws IOException
IOException
public static TiffIFDEntry getFirstIFDEntry(RandomAccessStream in, int tag) throws IOException
in
- the stream to retrieve the entry from.tag
- the tag of the entry to be retrieved.
IOException
- when there is an error accessing the stream in.public static Boolean checkHeader(RandomAccessStream in) throws IOException
IOException
public static long getFirstOffset(RandomAccessStream in) throws IOException
IOException
public static long getFirstOffset(RandomAccessStream in, boolean bigTiff) throws IOException
bigTiff
- true if this is a BigTIFF file (8 byte pointers).
IOException
public static Hashtable getIFD(RandomAccessStream in, long ifdNum, long offset) throws IOException
IOException
public static Hashtable getIFD(RandomAccessStream in, long ifdNum, long offset, boolean bigTiff) throws IOException
IOException
public static String getIFDTagName(int tag)
public static String getIFDTypeName(int type)
public static String getFieldName(int value)
public static Object getIFDValue(Hashtable ifd, int tag)
public static Object getIFDValue(Hashtable ifd, int tag, boolean checkNull, Class checkClass) throws FormatException
FormatException
public static long getIFDLongValue(Hashtable ifd, int tag, boolean checkNull, long defaultValue) throws FormatException
FormatException
public static int getIFDIntValue(Hashtable ifd, int tag)
public static int getIFDIntValue(Hashtable ifd, int tag, boolean checkNull, int defaultValue) throws FormatException
FormatException
public static TiffRational getIFDRationalValue(Hashtable ifd, int tag, boolean checkNull) throws FormatException
FormatException
public static long[] getIFDLongArray(Hashtable ifd, int tag, boolean checkNull) throws FormatException
FormatException
public static int[] getIFDIntArray(Hashtable ifd, int tag, boolean checkNull) throws FormatException
FormatException
public static short[] getIFDShortArray(Hashtable ifd, int tag, boolean checkNull) throws FormatException
FormatException
public static String getComment(String id) throws FormatException, IOException
FormatException
IOException
public static byte[][] getSamples(Hashtable ifd, RandomAccessStream in) throws FormatException, IOException
FormatException
IOException
public static byte[] getSamples(Hashtable ifd, RandomAccessStream in, byte[] buf) throws FormatException, IOException
FormatException
IOException
public static BufferedImage getImage(Hashtable ifd, RandomAccessStream in) throws FormatException, IOException
FormatException
IOException
public static void planarUnpack(short[][] samples, int startIndex, byte[] bytes, int[] bitsPerSample, int photoInterp, boolean littleEndian, int strip, int numStrips) throws FormatException
FormatException
public static void unpackBytes(short[][] samples, int startIndex, byte[] bytes, int[] bitsPerSample, int photoInterp, int[] colorMap, boolean littleEndian, long maxValue, int planar, int strip, int numStrips, long imageWidth) throws FormatException
FormatException
public static byte[] uncompress(byte[] input, int compression) throws FormatException, IOException
FormatException
IOException
public static void undifference(byte[] input, int[] bitsPerSample, long width, int planarConfig, int predictor) throws FormatException
FormatException
public static void putIFDValue(Hashtable ifd, int tag, Object value)
public static void putIFDValue(Hashtable ifd, int tag, short value)
public static void putIFDValue(Hashtable ifd, int tag, int value)
public static void putIFDValue(Hashtable ifd, int tag, long value)
public static void writeIFDValue(DataOutput ifdOut, ByteArrayOutputStream extraBuf, DataOutputStream extraOut, int offset, int tag, Object value) throws FormatException, IOException
ifdOut
- output object for writing IFD streamextraBuf
- buffer to which "extra" IFD information should be writtenextraOut
- data output wrapper for extraBuf (passed for efficiency)offset
- global offset to use for IFD offset valuestag
- IFD tag to writevalue
- IFD value to write
FormatException
IOException
public static void overwriteIFDValue(RandomAccessFile raf, int ifd, int tag, Object value) throws FormatException, IOException
FormatException
IOException
public static void overwriteComment(String id, Object value) throws FormatException, IOException
FormatException
IOException
public static long writeImage(BufferedImage img, Hashtable ifd, OutputStream out, int offset, boolean last) throws FormatException, IOException
img
- The field to writeifd
- Hashtable representing the TIFF IFD; can be nullout
- The output stream to which the TIFF data should be writtenoffset
- The value to use for specifying byte offsetslast
- Whether this image is the final IFD entry of the TIFF data
FormatException
IOException
public static long getImageWidth(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.public static long getImageLength(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.public static int[] getBitsPerSample(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.getSamplesPerPixel(Hashtable)
public static int getSamplesPerPixel(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.public static int getCompression(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.public static int getPhotometricInterpretation(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.public static long[] getStripOffsets(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.getStripByteCounts(Hashtable)
,
getRowsPerStrip(Hashtable)
public static long[] getStripByteCounts(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.getStripOffsets(Hashtable)
public static long[] getRowsPerStrip(Hashtable ifd) throws FormatException
ifd
- a TIFF IFD hashtable.
FormatException
- if there is a problem parsing the IFD metadata.public static byte[] compress(byte[] input, int compression) throws FormatException, IOException
FormatException
IOException
public static void difference(byte[] input, int[] bitsPerSample, long width, int planarConfig, int predictor) throws FormatException
FormatException
public static void debug(String message)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |