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

2004.07.26 13:25 "Re: [Tiff] Is this possible by using LibTiff?", by Joris Van Damme

# 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.

# 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 saw that we have a function ' TIFFRGBAImage ' to read the image data...

But we dont have a corrsponding "write" function. Also, the above function can cause loss of information/quality if bits per sample is more than 8.

...and it causes major criminally waste of space for singlebit pixel data, and it has trouble converting from/to stuff like CMYK, and it has no special provision for dealing with huge images which require special techniques, etc. It's really not meant to be a good interface, all by itself. Instead, use the RGBA series as either a) a hack at most common TIFFs, or b) excellent documentation on how to build your own interface to LibTiff, to your own needs. If you're into doing things properly, that's exactly what the strip and tile series are for. Again, consult LibTiff documentation,




Joris Van Damme
Download your free TIFF tag viewer for windows here: