1997.01.08 22:25 "libtiff to write EPS preview", by Chuck Packard

1997.01.10 16:28 "Re: libtiff to write EPS preview", by Niles Ritter

I've used the TIFF library successfully to write EPS with TIFF preview. First write out the 30 byte header leaving the TIFF position and size blank. Write out the EPS and close the file. Now open the file again with the TIFF library and start writing the TIFF at the end of the file. Record the start position and end position of the TIFF to fill into the 30 byte header. You might have to make some changes with the TIFF library and using the 'a' option when opening the file.

From the discussions I surmise that there is a practice to insert a TIFF preview inside an EPS file. I hope that this is well documented, as it makes me nervous, and sounds very fragile.

The problem is that TIFF is a *file* format, not a *stream* protocol, is not easily streamable, and the format is based on absolute file-offsets, not relative. Suppose I try to hack the libtiff library to append a TIFF file to the end of an EPS. What should it use for the offset to the first image directory: the absolute location in the EPS file, or the offset relative to the TIFF header? If you dont use the absolute location in the file, then passing the TIFF image directory to a naive TIFF file reader will fail when it seeks to the wrong location. On the other hand, if you use the absolute location then you will never be able to extract it from the EPS file, since the locations will all be wrong (and no one wants to reset all those StripOffset values, do they?).

Sounds bad in either case, although the header-relative approach seems like the "better" alternative. A minimally hacked libtiff file in "a" mode would probably generate absolute offsets, unfortunately, since it uses seeks to compute the locations of things.

Just out of curiosity, which approach is specified in EPS?

--Niles.