Class TiffDirectory
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.commons.imaging.formats.tiff.TiffElement
TiffElement.DataElement, TiffElement.Stub
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteOrder
private JpegImageData
final long
private TiffImageData
final int
Fields inherited from class org.apache.commons.imaging.formats.tiff.TiffElement
COMPARATOR, length, offset
-
Constructor Summary
ConstructorsConstructorDescriptionTiffDirectory
(int type, List<TiffField> entries, long offset, long nextDirectoryOffset, ByteOrder byteOrder) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
description
(int type) void
dump()
getFieldValue
(TagInfo tag) String[]
getFieldValue
(TagInfoAscii tag, boolean mustExist) byte
getFieldValue
(TagInfoByte tag) byte[]
getFieldValue
(TagInfoBytes tag, boolean mustExist) double
double[]
getFieldValue
(TagInfoDoubles tag, boolean mustExist) float
float[]
getFieldValue
(TagInfoFloats tag, boolean mustExist) getFieldValue
(TagInfoGpsText tag, boolean mustExist) int
getFieldValue
(TagInfoLong tag) int[]
getFieldValue
(TagInfoLongs tag, boolean mustExist) getFieldValue
(TagInfoRationals tag, boolean mustExist) byte
byte[]
getFieldValue
(TagInfoSBytes tag, boolean mustExist) short
int[]
getFieldValue
(TagInfoShortOrLong tag, boolean mustExist) short[]
getFieldValue
(TagInfoShorts tag, boolean mustExist) int
int[]
getFieldValue
(TagInfoSLongs tag, boolean mustExist) getFieldValue
(TagInfoSRationals tag, boolean mustExist) short
short[]
getFieldValue
(TagInfoSShorts tag, boolean mustExist) getFieldValue
(TagInfoXpString tag, boolean mustExist) getFloatingPointRasterData
(Map<String, Object> params) Reads the floating-point data stored in this TIFF directory, if available.private List
<TiffDirectory.ImageDataElement> getRawImageDataElements
(TiffField offsetsField, TiffField byteCountsField) int
Gets the image associated with the directory, if any.getTiffImage
(ByteOrder byteOrder) Gets the image associated with the directory, if any.getTiffImage
(ByteOrder byteOrder, Map<String, Object> params) Gets the image associated with the directory, if any.getTiffImage
(Map<String, Object> params) Gets the image associated with the directory, if any.boolean
boolean
Indicates whether the directory definition specifies a float-point data format.boolean
boolean
void
setJpegImageData
(JpegImageData value) void
setTiffImageData
(TiffImageData rawImageData)
-
Field Details
-
type
public final int type -
entries
-
nextDirectoryOffset
public final long nextDirectoryOffset -
tiffImageData
-
jpegImageData
-
headerByteOrder
-
-
Constructor Details
-
TiffDirectory
-
-
Method Details
-
description
-
getElementDescription
- Specified by:
getElementDescription
in classTiffElement
-
description
-
getDirectoryEntries
-
dump
public void dump() -
hasJpegImageData
- Throws:
ImageReadException
-
hasTiffImageData
- Throws:
ImageReadException
-
getTiffImage
Gets the image associated with the directory, if any. Note that not all directories contain images.- Returns:
- if successful, a valid BufferedImage instance.
- Throws:
ImageReadException
- in the event of an invalid or incompatible data format.IOException
- in the event of an I/O error.
-
getTiffImage
Gets the image associated with the directory, if any. Note that not all directories contain images.The optional parameters map can be used to specify image access or rendering options such as reading only a part of the overall image (i.e. reading a sub-image) or applying a custom photometric interpreter.
- Parameters:
params
- a map containing optional parameters to be applied to the read operation.- Returns:
- if successful, a valid BufferedImage instance.
- Throws:
ImageReadException
- in the event of an invalid or incompatible data format.IOException
- in the event of an I/O error.
-
getTiffImage
Gets the image associated with the directory, if any. Note that not all directories contain images.This method comes from an older version of this class in which byte order was required from an external source. Developers are encouraged to use the simpler version of getTiffImage that does not require the byte-order argument.
- Parameters:
byteOrder
- byte-order obtained from the containing TIFF file- Returns:
- if successful, a valid BufferedImage instance.
- Throws:
ImageReadException
- in the event of an invalid or incompatible data format.IOException
- in the event of an I/O error.
-
getTiffImage
public BufferedImage getTiffImage(ByteOrder byteOrder, Map<String, Object> params) throws ImageReadException, IOExceptionGets the image associated with the directory, if any. Note that not all directories contain images.This method comes from an older version of this class in which byte order was required from an external source. Developers are encouraged to use the simpler version of getTiffImage that does not require the byte-order argument.
- Parameters:
byteOrder
- byte-order obtained from the containing TIFF fileparams
- a map containing optional parameters to be applied to the read operation.- Returns:
- if successful, a valid BufferedImage instance.
- Throws:
ImageReadException
- in the event of an invalid or incompatible data format.IOException
- in the event of an I/O error.
-
findField
- Throws:
ImageReadException
-
findField
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getSingleFieldValue
- Throws:
ImageReadException
-
getSingleFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
public RationalNumber[] getFieldValue(TagInfoRationals tag, boolean mustExist) throws ImageReadException - Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
public RationalNumber[] getFieldValue(TagInfoSRationals tag, boolean mustExist) throws ImageReadException - Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getFieldValue
- Throws:
ImageReadException
-
getRawImageDataElements
private List<TiffDirectory.ImageDataElement> getRawImageDataElements(TiffField offsetsField, TiffField byteCountsField) throws ImageReadException - Throws:
ImageReadException
-
getTiffRawImageDataElements
- Throws:
ImageReadException
-
imageDataInStrips
- Throws:
ImageReadException
-
getJpegRawImageDataElement
- Throws:
ImageReadException
-
setTiffImageData
-
getTiffImageData
-
setJpegImageData
-
getJpegImageData
-
getFloatingPointRasterData
public TiffRasterData getFloatingPointRasterData(Map<String, Object> params) throws ImageReadException, IOExceptionReads the floating-point data stored in this TIFF directory, if available. Note that this method is defined only for TIFF directories that contain floating-point data.TIFF directories that provide floating-point data do not directly specify images, though it is possible to interpret the data as an image using this library. TIFF files may contain multiple directories which are allowed to have different formats. Thus it is possible for a TIFF file to contain a mix of image and floating-point raster data.
If desired, sub-image data can be read from the file by using a Java Map instance to specify the subsection of the image that is required. The following code illustrates the approach:
int x; // coordinate (column) of corner of sub-image int y; // coordinate (row) of corner of sub-image int width; // width of sub-image int height; // height of sub-image Map<String, Object>params = new HashMap<>(); params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, x); params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, y); params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, width); params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, height); TiffRasterData raster = directory.readFloatingPointRasterData(params);
- Parameters:
params
- an optional parameter map instance- Returns:
- a valid instance
- Throws:
ImageReadException
- in the event of incompatible or malformed dataIOException
- in the event of an I/O error
-
hasTiffFloatingPointRasterData
Indicates whether the directory definition specifies a float-point data format.- Returns:
- true if the directory contains floating point data; otherwise, false
- Throws:
ImageReadException
- in the event of an invalid or malformed specification.
-