From 3ed0fced1f22bcdb9a0f05bbbc1e3b87017ac8c2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 4 May 2020 06:29:46 +0300 Subject: qcam: dng_writer: Write EXIF IFD as custom directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The EXIF IFD is incorrectly chained to IFD 0 in addition to being a referenced as a sub IFD through the EXIFIFD tag. While the libtiff API doesn't clearly document why this happens, inspection of the TIFFWriteDirectory() source code show that the function treats the IFD being written as containing an image, which isn't correct for the EXIF IFD. Use TIFFWriteCustomDirectory() instead, which fixes the problem. The resulting DNG file can now be opened with darktable in addition to rawtherapee. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- src/qcam/dng_writer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/qcam') diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index ea4616f6..cbd8bed3 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -316,9 +316,7 @@ int DNGWriter::write(const char *filename, const Camera *camera, TIFFSetField(tif, EXIFTAG_EXPOSURETIME, exposureTime); } - TIFFCheckpointDirectory(tif); - exifIFDOffset = TIFFCurrentDirOffset(tif); - TIFFWriteDirectory(tif); + TIFFWriteCustomDirectory(tif, &exifIFDOffset); /* Update the IFD offsets and close the file. */ TIFFSetDirectory(tif, 0); -- cgit v1.2.1