-
-
Notifications
You must be signed in to change notification settings - Fork 888
Add Tiff Format Support #1553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tiff Format Support #1553
Conversation
[WIP] Implement Tiff codec
…ed methods and tests.
Implement simple unit-tests for Tiff decoder, add test files. Add benchmarks. Report decoder bugs.
In particular: * Support multi framing. * Using Metadata\Profiles\Exif\* types instead their duplicate tag types (moved to __obsolete directory). * Implement useful Metadata classes. * Add extensions. * Test coverage.
Implement Identify methods and add tests. Report not supported Predictor and SampleFormat features.
|
@brianpopow @IldarKhayrutdinov There's something very funky about how we determine encoding properties. I've done some work locally to make I'm gonna have to push a broken build as I don't know the spec enough to fix it. There's 3 failing tests. We should be using the I don't like the name |
I have removed this now from the
Fixed the failing tests with 508844a
|
|
@brianpopow thanks for the assist. I thought it was best to stop before I broke anything further 😅 Yes, I think we should use the enum directly and comment any unsupported members (same for anything else we’re proxying). Is this value something we should be capturing during decode in metadata to use if not set? |
|
@JimBobSquarePants @brianpopow sorry for delay Really there is dilemma Anyway, the encoder parses the parameters and adjust them safely. Missing/default parameters as before can be taken from an exist frame metadata. Those the dilemma concerns only user API.
Also, in the future, when will be support for writing multi-frames, for each frame the options may be different, how will make options API? |
|
Yep, we really do not want to abstract elements present in the specification, anyone changing properties would be familiar with Tiff. I would change the options to the following. All properties should be nullable with the core encoder determining the correct value to set using first any metadata parsed from decode as default when not set, then a sensible default. Note the lack of constructors, this is by design. public class TiffEncoder : IImageEncoder, ITiffEncoderOptions
{
public TiffBitsPerPixel? BitsPerPixel { get; set; }
public TiffCompression? Compression { get; set; }
public DeflateCompressionLevel? CompressionLevel { get; set; }
public TiffPhotometricInterpretation? PhotometricInterpretation { get; set; }
public TiffPredictor? HorizontalPredictor { get; set; }
public IQuantizer Quantizer { get; set; }
}The hierarchy should be as follows. How many of the above properties can we parse on decode? Note, upon re-reading |
|
I have changed the EncodingMode now to be the TiffPhotometricInterpretation: d22692e
Yeah it was indeed complicated. There are alot of possible combinations, I hope i have got now all valid combinations covered with tests. I have the feeling i have forgotten some. I have changed the TiffEncoder Options as James suggested above.
We got |
OK.... So I know we've gone round in circles a lot here but do you both think we should populate the |
While I think it makes sense accessing those values a bit more convenient for the user, it will introduce the problem for us, that we have the same information in two places So im not totally convinced about the idea. @IldarKhayrutdinov what is your opinion on that? |
@JimBobSquarePants totally agree, briefly and clear!
Yeah, the example with
@brianpopow Yeah, it’s a problem that the same information is in several places. I think there are 2 ways, needs to choose one of them and take it as agreement.
EncoderOptions > ImageFrameMetadata.ExifProfile > Default
EncoderOptions > TiffFrameMetadata > Default |
So option 1 is basically what we have right now. For option 2. we would add |
|
Yep so Options 2 seems sound. |
Ok option 2 it is then, see 11a4e20. I have also removed the values from the ExifProfile. |
…rimary source of truth
|
I can't actually hit approve on this (since I created this version of the PR) but I think it's ready to hit the main branch! Congratulations @Andy-Wilkinson @brianpopow @IldarKhayrutdinov and anyone else I've missed. This is such a MASSIVE achievement! |
I took quite some while to finish this, but I am now very happy what we achieved! Thanks a lot to @Andy-Wilkinson for starting the work on the tiff branch and also of course @IldarKhayrutdinov who contributed to this branch and also helped with his opinions on all things tiff related! |
|
I'm happy to contribute! 🎉 |

Prerequisites
Description
Note: This Replaces #1456 which cannot be reopened following a force push.
This PR adds support for TIFF decoding and encoding.
The specification can be found here: TIFF spec
Or as a PDF in the tiff folder (ImageSharp\Formats\Tiff).
Currently the Encoder and Decoder support the following:
Baseline TIFF
TIFF Extensions
The following extension features will probably not be part of the first release of the TIFF format support.
TODO's
Issue with LZW decoding with some images, for example:Fixed with #12 Tiff specific fixes for LZW #1457rgb_lzw_no_predictor.tiffThere is still an issue with LZW. Compression a byte array with LZW and then decompress it again does not yield in the original byte array. See failing tests.fixed with da51a4f