Fix TIFF export with EXIF data and I/O proxy #4300
Open
+25
−7
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.
TIFF export with EXIF metadata (e.g. oiio::ColorSpace) creates invalid TIFF files in the presence of an I/O proxy ("TIFF directory is missing required "ImageLength" field"). The reasons is that TIFFSetDirectory() requires to read some of the previously written data, but neither writer_readproc() nor the available proxy implementations support that. Note that TIFF output does not yet use this new scheme for I/O proxy that was used for many other plugins.
I think writer_readproc() should not take any shortcuts and just forward the call to the I/O proxy.
Is there a reason why IOFile (in write mode) and IOVecOutput do not allow to re-read written data? This looks like an artificial restriction of the underlying resources. An alternative not modifiying these two implementations would be to let the TIFF output use a variant of IOVecOutput that allows re-reading and forward all data at the very end to the passed-in proxy.
Is there some policy to add assertions in all methods that are not supposed to be called? This would have helped here a lot to reduce the test case.
Tests
I did not add an explicit test. I guess the proper way would be to convert TIFF ouput to use the same I/O proxy scheme that is used by many other plugins. Small repro case is attached.
repro.cpp.txt
Checklist:
(adding new test cases if necessary). See above.
corresponding Python bindings (and if altering ImageBufAlgo functions, also
exposed the new functionality as oiiotool options).
already run clang-format before submitting, I definitely will look at the CI
test that runs clang-format and fix anything that it highlights as being
nonconforming.