Skip to content
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

Fix TIFF export with EXIF data and I/O proxy #4300

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jreichel-nvidia
Copy link
Contributor

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:

  • 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).
  • 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.

TIFFSetDirectory() requires to read some of the previously written data. Change
writer_readproc() to forward the call to the I/O proxy.

Modify IOFile to also support reading after writing (in write mode).

Modify IOVecOutput to also support reading (implicitly after writing, since the
vector starts always empty).

Signed-off-by: Joachim Reichel <[email protected]>
Signed-off-by: Joachim Reichel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant