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

The output.dng produced by the dngwriter example does not pass DNG validation #44

Open
mallman opened this issue Jul 23, 2024 · 2 comments

Comments

@mallman
Copy link

mallman commented Jul 23, 2024

First of all, thank you for publishing tinydng. Just as I was starting to resign myself to using the enormous and complex Adobe DNG SDK, I come across tinydng. I hope it's the answer to my prayers.

I want to use tinydng to write a synthesized CFA DNG file. I am looking to the dngwriter example for guidance. It's helpful, but it doesn't demonstrate the construction of a DNG with the CFA photometric interpretation. That's beside the point of this issue, but if you can point me to an example of using tinydng to write a CFA DNG file that would be awesome. :)

Returning to the meat of this issue, it appears that the output.dng file written by the dngwriter example does not conform to the DNG specification.

The first issue is the file does not declare a DNGVersion. According to the specification, this is a required tag.

Second, the specification states that the RGB Photometric interpretation is valid for previews and thumbnails only. However output.dng sets that tag for the raw IFD.

I don't think that that noncomformity is correctible. If I understand correctly, dngwriter is attempting to write an RGB image as a "negative". The DNG spec just doesn't seem to allow that. (Incidentally, the spec does mention that the LinearRaw photometric interpretation can be used for de-mosaiced data. This may allow for the use of an RGB image as a "negative", but I wasn't able to get this to work.)

I discovered the mentioned errors by running dng_validate from the Adobe SDK on output.dng.

For example, if I modify main.cc to set the DNGVersion to 1.1.0.0, then I get

dng_validate output.dng
Validating "output.dng"...
*** Warning: Chained IFD 1 BitsPerSample has odd data offset (1572899) ***
*** Warning: Chained IFD 1 ImageDescription has odd data offset (1572921) ***
*** Warning: Chained IFD 1 XResolution has odd data offset (1572905) ***
*** Warning: Chained IFD 1 YResolution has odd data offset (1572913) ***
*** Warning: Missing or invalid UniqueCameraModel ***
*** Warning: This file has Chained IFDs, which will be ignored by DNG readers ***
*** Error: PhotometricInterpretation requires NewSubFileType = 1 (IFD 0) ***

I'm not familiar enough with either the TIFF or DNG spec to truly understand the warnings, but the error seems straightforward enough.

@syoyo
Copy link
Owner

syoyo commented Jul 23, 2024

Thanks for the detailed description.

I didn't realized there is a DNG validator, its good to know such a tool exists.

Anyway, making TinyDNG-writer-produced DNG conformant to the DNG spec would require some amount of work. So the priority to making it DNG spec conformant it is low at the moment. You can increase the priority by either:

  • Sponsor TinyDNG project 🥺🙏
  • Contribute TinyDNG writer to make it conformant to DNG spec.

@mallman
Copy link
Author

mallman commented Jul 23, 2024

Hi @syoyo.

To clarify, I'm not suggesting that there's anything wrong with tiny_dng_writer.h. In fact, I'm using it to write conformant DNG files.

The trouble I found is with the example app itself. I've used it as a springboard to get where I need to be. In that way it's been very useful. I've used dng_validator and the spec as a guide to see what code I need to adjust. But the example itself does not produce a spec-conformant DNG file. And I don't know how to fix it.

Thanks again.

@mallman mallman changed the title The output.dng produced by the dngwriter example is does not pass DNG validation The output.dng produced by the dngwriter example does not pass DNG validation Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants