Class TIFFImageWriteParam
ImageWriteParam
allowing control over the TIFF writing process. The set of innately
supported compression types is listed in the following table:
Compression Type | Description | Reference |
---|---|---|
CCITT RLE | Modified Huffman compression | TIFF 6.0 Specification, Section 10 |
CCITT T.4 | CCITT T.4 bilevel encoding/Group 3 facsimile compression | TIFF 6.0 Specification, Section 11 |
CCITT T.6 | CCITT T.6 bilevel encoding/Group 4 facsimile compression | TIFF 6.0 Specification, Section 11 |
LZW | LZW compression | TIFF 6.0 Specification, Section 13 |
JPEG | "New" JPEG-in-TIFF compression | TIFF Technical Note #2 |
ZLib | "Deflate/Inflate" compression (see note following this table) | Adobe Photoshop® TIFF Technical Notes (PDF) |
PackBits | Byte-oriented, run length compression | TIFF 6.0 Specification, Section 9 |
Deflate | "Zip-in-TIFF" compression (see note following this table) | ZLIB Compressed Data Format Specification, DEFLATE Compressed Data Format Specification |
EXIF JPEG | EXIF-specific JPEG compression (see note following this table) | EXIF 2.2 Specification (PDF), section 4.5.5, "Basic Structure of Thumbnail Data" |
Old-style JPEG compression as described in section 22 of the TIFF 6.0 Specification is not supported.
The CCITT compression types are applicable to bilevel (1-bit) images only. The JPEG compression type is applicable to byte grayscale (1-band) and RGB (3-band) images only.
ZLib and Deflate compression are identical except for the value of the TIFF Compression field: for ZLib the Compression field has value 8 whereas for Deflate it has value 32946 (0x80b2). In both cases each image segment (strip or tile) is written as a single complete zlib data stream.
"EXIF JPEG" is a compression type used when writing the contents of an APP1 EXIF marker segment for inclusion in a JPEG native image metadata tree. The contents appended to the output when this compression type is used are a function of whether an empty or non-empty image is written. If the image is empty, then a TIFF IFD adhering to the specification of a compressed EXIF primary IFD is appended. If the image is non-empty, then a complete IFD and image adhering to the specification of a compressed EXIF thumbnail IFD and image are appended. Note that the data of the empty image may not later be appended using the pixel replacement capability of the TIFF writer.
If ZLib/Deflate or JPEG compression is used, the compression quality may be set. For ZLib/Deflate the supplied floating point quality value is rescaled to the range [1, 9] and truncated to an integer to derive the Deflate compression level. For JPEG the floating point quality value is passed directly to the JPEG writer plug-in which interprets it in the usual way.
The canWriteTiles
and
canWriteCompressed
methods will return
true
; the canOffsetTiles
and
canWriteProgressive
methods will return
false
.
If tiles are being written, then each of their dimensions will be rounded to the nearest multiple of 16 per the TIFF specification. If JPEG-in-TIFF compression is being used, and tiles are being written each tile dimension will be rounded to the nearest multiple of 8 times the JPEG minimum coded unit (MCU) in that dimension. If JPEG-in-TIFF compression is being used and strips are being written, the number of rows per strip is rounded to a multiple of 8 times the maximum MCU over both dimensions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
(package private) TIFFColorConverter
(package private) TIFFCompressor
(package private) int
Fields inherited from class javax.imageio.ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, compressionMode, compressionQuality, compressionType, compressionTypes, locale, MODE_COPY_FROM_METADATA, MODE_DEFAULT, MODE_DISABLED, MODE_EXPLICIT, preferredTileSizes, progressiveMode, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, tilingMode, tilingSet
Fields inherited from class javax.imageio.IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
-
Constructor Summary
ConstructorsConstructorDescriptionTIFFImageWriteParam
(Locale locale) Constructs aTIFFImageWriteParam
instance for a givenLocale
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the currentTIFFColorConverter
object that will be used to perform color conversion when writing the image, ornull
if none is set.int
Returns the current value that will be written to thePhotometricinterpretation
tag.Returns theTIFFCompressor
that is currently set to be used by theImageWriter
to encode each image strip or tile, ornull
if none has been set.boolean
void
setColorConverter
(TIFFColorConverter colorConverter, int photometricInterpretation) Sets theTIFFColorConverter
object describing the color space to which the input data should be converted for storage in the input stream.void
setTIFFCompressor
(TIFFCompressor compressor) Sets theTIFFCompressor
object to be used by theImageWriter
to encode each image strip or tile.void
Removes any currently setColorConverter
object andPhotometricInterpretation
tag value.Methods inherited from class javax.imageio.ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, getBitRate, getCompressionMode, getCompressionQuality, getCompressionQualityDescriptions, getCompressionQualityValues, getCompressionType, getCompressionTypes, getLocale, getLocalizedCompressionTypeName, getPreferredTileSizes, getProgressiveMode, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTilingMode, setCompressionMode, setCompressionQuality, setCompressionType, setProgressiveMode, setTiling, setTilingMode, unsetCompression, unsetTiling
Methods inherited from class javax.imageio.IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceBands, setSourceRegion, setSourceSubsampling
-
Field Details
-
compressor
TIFFCompressor compressor -
colorConverter
TIFFColorConverter colorConverter -
photometricInterpretation
int photometricInterpretation -
appendedCompressionType
private boolean appendedCompressionType
-
-
Constructor Details
-
TIFFImageWriteParam
Constructs aTIFFImageWriteParam
instance for a givenLocale
.- Parameters:
locale
- theLocale
for which messages should be localized.
-
-
Method Details
-
isCompressionLossless
public boolean isCompressionLossless()- Overrides:
isCompressionLossless
in classImageWriteParam
-
setTIFFCompressor
Sets theTIFFCompressor
object to be used by theImageWriter
to encode each image strip or tile. A value ofnull
allows the writer to choose its own TIFFCompressor.Note that invoking this method is not sufficient to set the compression type:
must be invoked explicitly for this purpose. The following code illustrates the correct procedure:setCompressionType()
TIFFImageWriteParam writeParam; TIFFCompressor compressor; writeParam.setCompressionMode(writeParam.MODE_EXPLICIT); writeParam.setTIFFCompressor(compressor); writeParam.setCompressionType(compressor.getCompressionType());
IfcompressionType
is set to a value different from that supported by theTIFFCompressor
then the compressor object will not be used.If the compression type supported by the supplied
TIFFCompressor
is not among those in
, then it will be appended to this array after removing any previously appended compression type. IfcompressionTypes
compressor
isnull
this will also cause any previously appended type to be removed from the array.- Parameters:
compressor
- theTIFFCompressor
to be used for encoding, ornull
to allow the writer to choose its own.- Throws:
IllegalStateException
- if the compression mode is notMODE_EXPLICIT
.- See Also:
-
getTIFFCompressor
Returns theTIFFCompressor
that is currently set to be used by theImageWriter
to encode each image strip or tile, ornull
if none has been set.- Returns:
- compressor the
TIFFCompressor
to be used for encoding, ornull
if none has been set (allowing the writer to choose its own). - Throws:
IllegalStateException
- if the compression mode is notMODE_EXPLICIT
.- See Also:
-
setColorConverter
Sets theTIFFColorConverter
object describing the color space to which the input data should be converted for storage in the input stream. In addition, the value to be written to thePhotometricInterpretation
tag is supplied.- Parameters:
colorConverter
- aTIFFColorConverter
object, ornull
.photometricInterpretation
- the value to be written to thePhotometricInterpretation
tag in the root IFD.- See Also:
-
getColorConverter
Returns the currentTIFFColorConverter
object that will be used to perform color conversion when writing the image, ornull
if none is set.- Returns:
- a
TIFFColorConverter
object, ornull
. - See Also:
-
getPhotometricInterpretation
public int getPhotometricInterpretation()Returns the current value that will be written to thePhotometricinterpretation
tag. This method should only be called if a value has been set using thesetColorConverter
method.- Returns:
- an
int
to be used as the value of thePhotometricInterpretation
tag. - Throws:
IllegalStateException
- if no value is set.- See Also:
-
unsetColorConverter
public void unsetColorConverter()Removes any currently setColorConverter
object andPhotometricInterpretation
tag value.- See Also:
-