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

1997.01.09 07:36 "Re: libtiff to write EPS preview", by Karsten Spang

Well, I of course did not write without a question. Or maybe it is an enhancement request. I want to also use libtiff to output a TIFF preview for an EPS file. To do that, I have to output the PostScript and then the TIFF to the same file; along with a 30 byte header that precedes both. Looks like I can call TIFFOpen with 'a' to tack the TIFF onto the EPS file. But I also need to specify the length of the TIFF image in the header.

Doesn't work. The 'a' means "apppend an image to an existing TIFF file.

How can one find out how many bytes were written out for a TIFF image? If I use no compression, then it is just width * height * 3 + H, were H is some amount of TIFF header (tag) information. Anyone know what H is?

No, H is not well defined by the TIFF spec. It may easily vary between libtiff versions.

What if I do use packbits compression; how long is the file then? I guess what would be great is some function I can call after TIFFClose that tells me how many bytes were written out. When I looked at the code for PackBitsEncodeI do not see any magical global keeping track of how many bytes are being written out with each encoded strip. So I do not see an easy modification to get at this information. Anyone ever look into this? Anyone else need this?

Even worse...

My suggestion:

Create a separate TIFF file, use stat() to find its size, insert it into the EPS file, remove() it.

If you don't like that, you may want to use TIFFClientOpen() with your own routines to write into memory, keeping track of the size, and write the stuff to the EPS file later. Warning: this may turn out to be pretty hairy...

Karsten
--------------------------------------------------------------------------------
E-mail: krs@kampsax.dk                                      Karsten Spang
Phone:  +45 36 39 08 00                                     Kampsax Technology
Fax:    +45 36 77 03 01                                     P.O. Box 1142
WWW:    http://www.kampsax.dk/~krs                          DK-2650 Hvidovre
                                                            Denmark