I've changed the code so that it reads:

                    // Go back to the first (main) directory, and set
correct value of the

                    // EXIFIFD pointer. Note that the directory is reloaded
from the file!

                    //

                    TIFFSetDirectory(m_tiff, 0);

                    TIFFSetField(m_tiff, TIFFTAG_EXIFIFD, dir_offset_EXIF);

                    TIFFWriteDirectory(m_tiff);

                    TIFFSetDirectory(m_tiff, 0);
             }

 

So that should sort the problem? Is that right?

 

Thanks,David

 

From: Sulau <su...@freenet.de> 
Sent: 12 April 2023 17:26
To: 'David C. Partridge' <david.partri...@perdrix.co.uk>
Cc: tiff@lists.osgeo.org
Subject: Re: [Tiff] TIffWriteDirectory() causes problems

 

Hi David

 

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().

 

Regards

Su

_______________________________________________
Tiff mailing list
Tiff@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/tiff

Reply via email to