AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2023.04.12 15:14 "[Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.12 16:26 "Re: [Tiff] TIffWriteDirectory() causes problems", by Sulau
2023.04.12 20:24 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.13 09:32 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.13 12:15 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.13 12:26 "Re: [Tiff] TIffWriteDirectory() causes problems", by Olivier Paquet
2023.04.13 13:16 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.13 13:16 "Re: [Tiff] TIffWriteDirectory() causes problems", by Olivier Paquet
2023.04.13 14:08 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.13 15:24 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge
2023.04.13 15:24 "Re: [Tiff] TIffWriteDirectory() causes problems", by Olivier Paquet

2023.04.13 12:15 "Re: [Tiff] TIffWriteDirectory() causes problems", by David C. Partridge

I eventually worked out what was happening:

The very act of 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 EXIF IFD being overwritten. and the file therefore failed validation. Therefore, there's no way to avoid the base IFD being at the end of the file.