OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

Fix TIFF export with EXIF data and I/O proxy

Open jreichel-nvidia opened this issue 1 year ago • 0 comments

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:

  • [x] I have read the contribution guidelines.
  • [n/a] I have updated the documentation, if applicable.
  • [ ] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary). See above.
  • [n/a] If I added or modified a C++ API call, I have also amended the corresponding Python bindings (and if altering ImageBufAlgo functions, also exposed the new functionality as oiiotool options).
  • [x] My code follows the prevailing code style of this project. If I haven't 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.

jreichel-nvidia avatar Jun 18 '24 12:06 jreichel-nvidia