Class Compression
Object
Compression
- All Implemented Interfaces:
Serializable
The compression method used for writing GeoTIFF files.
This class specifies only the compressions supported by the Apache SIS writer.
The Apache SIS reader supports more compression methods, but they are not listed in this class.
If no compression is explicitly specified, Apache SIS uses by default the
The compression to use can be specified as an option when opening the data store. For example for writing a TIFF file without compression, the following code can be used:
var file = Path.of("my_output_file.tiff");
var connector = new StorageConnector(file);
connector.setOption(Compression.OPTION_KEY, Compression.NONE);
try (GeoTiffStore ds = new GeoTiffStore(null, connector)) {
// Write data here.
}
DEFLATE
compression.- Since:
- 1.5
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Compression
Deflate compression (like ZIP format) with a default compression level and a default predictor.static final Compression
No compression, but pack data into bytes as tightly as possible.static final OptionKey
<Compression> The key for declaring the compression at store creation time. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this compression with the given object for equality.int
Returns a hash code value for this compression.level()
Returns the current compression level.Returns the current predictor.Returns a string representation of this compression.withLevel
(int value) Returns an instance with the specified compression level.withPredictor
(int value) Returns an instance with the specified predictor.
-
Field Details
-
NONE
No compression, but pack data into bytes as tightly as possible. -
DEFLATE
Deflate compression (like ZIP format) with a default compression level and a default predictor. This is the compression used by default by the Apache SIS GeoTIFF writer.Predictors
The compression ratio can sometime be improved by the use of a predictor. For example instead of specifyingDEFLATE
directly to theStorageConnector
options, the following can be specified:Compression.DEFLATE.withPreductor(BaselineTIFFTagSet.PREDICTOR_HORIZONTAL_DIFFERENCING);
withPredictor(int)
should be invoked explicitly.- See Also:
- "TODO:"
- Compute Shannon Entropy with and without predictor on a few sample rows for deciding automatically which predictor to use.
-
OPTION_KEY
The key for declaring the compression at store creation time. See class Javadoc for usage example.- See Also:
-
-
Method Details
-
withLevel
Returns an instance with the specified compression level. The value can range from 1 to 9 inclusive. A value of 0 returnsNONE
. A value of -1 resets the default compression. This method does nothing if this compression does not support compression levels.- Parameters:
value
- the new compression level (0-9), or -1 for the default compression.- Returns:
- a compression of the specified level.
- Throws:
IllegalArgumentException
- if the given value is not in the expected range.- See Also:
-
level
Returns the current compression level. The returned value is between 0 and 9 inclusive.- Returns:
- the current compression level, or an empty value for the default level.
-
withPredictor
Returns an instance with the specified predictor. A predictor is a mathematical operator that is applied to the image data before an encoding scheme is applied. Predictors sometime improve the result of some compression algorithms such asDEFLATE
.The given predictor may be ignored if it is unsupported by this compression. For example invoking this method on
NONE
has no effect.- Parameters:
value
- one of thePREDICTOR_*
constants ininvalid reference
BaselineTIFFTagSet
- Returns:
- a compression using the specified predictor.
- Throws:
IllegalArgumentException
- if the given value is not valid.- See Also:
-
predictor
Returns the current predictor. The returned value is one of thePREDICTOR_*
constants defined ininvalid reference
BaselineTIFFTagSet
- Returns:
- one of the
PREDICTOR_*
constants, or empty if predictor does not apply to this compression.
-
equals
-
hashCode
-
toString
-