2004.07.26 10:07 "[Tiff] Is this possible by using LibTiff?", by Sachin Garg

2004.07.29 09:16 "Re: [Tiff] Is this possible by using LibTiff?", by Sachin Garg

# 1. Is it possible to just store the Tiff Directory with all tags except-the-image-pixel-data, so that I can later easily recreate a Tiff with same characteristics as the original file?

I don't think exactly this functionality is included in LibTiff. I wouldn't advice this exact way of doing it, anyhow. Either

  1. the tags-except-image-pixel data stuff is fixed. In that case, hard-code it
  2. the tags-except-image-pixel data stuff is flexible. Perhaps there's a UI somewhere or another application somewhere that builds these 'tagsets', and the same code has to be able to mix the flexible tagset and the image data. In that case, I advise designing a proprietary data file format for these tagsets. Could be based on TIFF, could even be based on LibTiff, but make sure you don't copy the TIFF header in this proprietary tagset data file format, or you're bound to cause trouble in the end. For instance, the proprietary format could be as simple as a single TIFF IFD with auxiliary tag data, not including a TIFF file header, or the 'next IFD' pointer. Consult the TIFF spec on this, it's quite simple.

Its actually coming from another Tiff file... what I am planning to do is to read in a tiff directory (using libtiff), and then write it out to another tiff, this way, I can again read in that second tiff (again using libtiff) to getback the same directory with all the same tagvalues.

(I will take care to manually destroy the TIFF header in this file to avoid confusion)

# 2. Assuming that I have the above directory of tags, and a buffer with all the image data... how can i recreate the tiff?

Consult your LibTiff documentation, and the LibTiff utilities code. It's all there.

I have all the image data as single buffer, and I want to restore it back having the same tiling/stripping configuration as it originally had. (These settings I will be writting to that image's directory as mentioned above)

It seems I will have to manaully divide the image into pieces to recreate the strips and tiles and then use the strip and tile writting routines, or is there some routine in LibTiff (or its tools) which can do it for me.

Sachin Garg