V4 TIFF : Allow additional and undefined extra samples#2941
Merged
JimBobSquarePants merged 1 commit intomainfrom Jun 12, 2025
Merged
V4 TIFF : Allow additional and undefined extra samples#2941JimBobSquarePants merged 1 commit intomainfrom
JimBobSquarePants merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR relaxes restrictions on TIFF files with additional or undefined extra samples, enhancing compatibility with real-world files.
- Added a new test image and corresponding test reference for TIFFs with unspecified extra samples.
- Updated the TiffExtraSampleType enum to include a CorelDRAW-specific value and modified the decoder options parser to patch this value for compatibility.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Images/Input/Tiff/Issues/ExtraSamplesUnspecified.tif | New test image added to support the updated extra samples behavior. |
| tests/ImageSharp.Tests/TestImages.cs | Constant updated to include the new test image path. |
| tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs | New test case added for verifying decoding of TIFF files with unspecified extra samples. |
| src/ImageSharp/Formats/Tiff/TiffExtraSampleType.cs | Enum updated to include CorelDrawUnassociatedAlphaData with explanatory comments. |
| src/ImageSharp/Formats/Tiff/TiffDecoderOptionsParser.cs | Decoder options logic updated to support the new extra sample type and patch incompatible values. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
See #2408
This PR removes explicit validation checks that disallow TIFF files with unspecified or multiple
TiffExtraSampleTypevalues. These checks are unnecessary and overly restrictive.Rationale
Decoder logic already defends against unsupported configurations
The decoding path only processes known and supported sample layouts (e.g., RGB + unassociated alpha). Unsupported layouts naturally fail at the point of use without requiring upfront rejection.
Unspecified extra samples cannot be meaningfully decoded
According to the TIFF specification,
TiffExtraSampleType.UnspecifiedDataprovides no semantic meaning. There is no way to determine how such channels should be interpreted. Since these channels carry no defined role, the decoder either discards them or ignores them during processing. Explicit rejection is redundant.Improved compatibility with real-world files
TIFFs produced by some tools (e.g., legacy or proprietary software) may include extra channels with incomplete or non-standard metadata. Allowing the decoder to handle these cases gracefully increases format compatibility without compromising decoder integrity.
Notes
ExtraSamples, such as the CorelDRAW-specific999value.See libtiff 3.9.0beta release