2023.04.12 16:26 "Re: [Tiff] TIffWriteDirectory() causes problems", by Sulau
The TIFF documentation of TIFF WriteDirectory() says:
" <http://www.simplesystems.org/libtiff/functions/TIFFWriteDirectory.html#c.TI FFWriteDirectory> TIFFWriteDirectory() will write the contents of the current directory (IFD) to the file and setup to create a new directory (IFD) using <http://www.simplesystems.org/libtiff/functions/TIFFCreateDirectory.html#c.T IFFCreateDirectory> TIFFCreateDirectory(). "
This means that then m_tiff points to a new, empty directory and therefore TiffScanlineSize() returns zero.
If you want to go back to the previously written IFD you have to use TIFFSetDirectory(m_tiff, dirnumber), which re-reads the IFD (dirnumber) from file.
Or you could first write the image data straight after "TIFFSetField(m_tiff, TIFFTAG_EXIFID, dir_offset_EXIF);" and then call TIFFWriteDirectory() just before TIFFClose().