Closed perdrix52 closed 1 year ago
Hi @perdrix52 I'd like to reproduce this but might need a little more information. Which library are you using to create the files please? Is it possible that you might be able to attach two as examples here please?
I'm using libtiff 4.5.0 I can provide source code and a link to a LARGE file (sorry my software processes large images.).
https://www.dropbox.com/s/moe5rtp4wg1ra21/MasterOffset_ISO200.tif?dl=1
Source code attached: the mfs you want to look at are CTIFFWriter::Open(), CTIFFWriter::Write() and CTIFFWriter::Close() TIFFUtil.zip
I can read tags in the base IFD find but failed to TIFFReadEXIFDirectory() so the file is definitely somewhat damaged
Thanks David
Never mind I worked it out - writing the data added two additional fields to the base IFD - specifically:
StripOffsets (3 Long): 514, 16771762, 33543010 StripByteCounts (3 Long): 16771248, 16771248, 2496960
They were added by the libtiff code internally (not by my code).
Which meant that the base IFD was larger after writing the data than it was before. Thus TIFFWriteDirectory over-wrote the EXIF IFD resulting in the mess above!!! Therefore there's no way to avoid the base IFD being at the end of the file.
That makes sense. Thanks for the follow-up info and explanation.
I'm trying to force a TIFF file I write to have the main IFD at the beginning rather then the end.
So when I have written all the TIFF tags to the main IFD, I switch to create the EXIF IFD, populate that and then issue:
then I write the image data.
If just TIFFClose at that point jHove is happy with the file:
If I add a call to TIFFWriteDirectory immediately before the call to TIFFClose, jHove detects as an ascii bytestream, and if I invoke it with -m TIFF-hul, I get:
Is this me or jHove? I can process the file quite happily - and it opens in Photoshop/GIMP/IfranView etc. just fine ...
Thanks David