These samples are normal bits in the encoded (e.g. compressed) stream of each tile or row of the image. However, when considering the photometric interpretation of an image these samples should be discarded. They are only relevant for multiband. For the most part we previously rejected these images due to a mismatch between sample count and the color as indicated by the interpretation. Only, for alpha we never really verified if the extra channel is indeed alpha or something unrelated. We don't have a perfect solution as GeoTiff motivates us having a MultiBand pseudo-color output configuration that has no related photometric interpretation and borrows the usual gray tone instead. We can only really distinguish this from a gray-alpha image through looking at the values of the ExtraSamples vector. Then again we do not yet support GrayAlpha anyways. As a simplification for the discarding process we only support full-byte extra samples and require all samples to be the same bit-depth, not only those which we return. This is blessed by Tiff's recommendations for baseline decoding as well as libtiff.
image-tiff
TIFF decoding and encoding library in pure Rust
Supported
Features
- Baseline spec (other than formats and tags listed below as not supported)
- Multipage
- BigTIFF
- Incremental decoding
Formats
This table lists photometric interpretations and sample formats which are supported for encoding and decoding. The entries are ColorType variants for which sample bit depths are supported. Only samples where all bit depths are equal are currently supported. For example, RGB(8) means that the bit depth [8, 8, 8] is supported and will be interpreted as an 8 bit per channel RGB color type.
PhotometricInterpretation |
UINT Format | IEEEFP Format |
|---|---|---|
WhiteIsZero |
Gray(8|16|32|64) | Gray(32|64) |
BlackIsZero |
Gray(8|16|32|64) | Gray(32|64) |
RGB |
RGB(8|16|32|64), RGBA(8|16|32|64) | RGB(32|64), RGBA(32|64) |
RGBPalette |
||
Mask |
||
CMYK |
CMYK(8|16|32|64) | CMYK(32|64) |
CMYKA |
CMYKA(8) | |
YCbCr |
||
CIELab |
Compressions
| Decoding | Encoding | |
|---|---|---|
| None | ✓ | ✓ |
| LZW | ✓ | ✓ |
| Deflate | ✓ | ✓ |
| PackBits | ✓ | ✓ |
| Fax4 | ✓ | not yet |
| JPEG | ✓ | not yet |
| ZSTD | ✓ | not yet |
Not yet supported
Formats and interpretations not listed above or with empty entries are unsupported.
- Baseline tags
ExtraSamples
- Extension tags
Fuzzing
This crate uses cargo-fuzz in order to test the image parser.
After installing it with cargo install cargo-fuzz on a nightly rustc, the
fuzzing harness can be run with recommended settings using
cargo fuzz run decode_image -snone -- -timeout=5.