2000.07.28 13:33 "Extracting previews", by Steve Roy

2000.07.28 14:14 "Re: Extracting previews", by Helge Blischke

I built and linked libtiff into my Macintosh application. It works fine. I can now read TIFF images from files and display them in a window.

Now what I really need to do is display TIFF previews extracted from EPS files. The EPS files are generated using various graphics program, such as QuarkXPress and Creator2.

Where can I find out how to extract the TIFF preview from the EPS file? I know the TIFF preview is preceeded with 'C5D0D3C6', but the data I see with my HEX editor doesn't look at all like TIFF data. I tried making a new file with this data and reading it but no software recognizes it as a TIFF file.

I think most of the Mac apps packk the preview into one of the resources contained in the resource fork, and mostly they use quickdraw previews.

When using TIFF as preview format, they usually use the so called "DOS-EPS" format which is the same as used on Wintel platforms. The "C5D0D3C6" hex codes are an obfuscated "EPSF" string which is the "macig number" of the DOS-EPSF header. The rest of the header is structured as follows:

Byte    contents
---------------------------
0-3     the above mentioned magic number
4-7     position of PostScript code
8-11    length of PostScript code
12-15   position of Metafile preview
16-19   length of Metafile preview
20-23   position of TIFF preview
24-27   length of TIFF preview
28-29   checksum (XOR of bytes 0 to 27) or FFFF

All positions are byte positions releative to the beginning of the file, the first byte (the "C5" being at position 0), all length values are byte counts, and the integer values all are little-endian, i.e. the least significant byte comes first.

There should be only one preview (either TIFF or metafile), the position and length of the other should be zero.

Hope that helps

Helge

H.Blischke@srz-berlin.de
H.Blischke@srz-berlin.com
H.Blischke@acm.org