1999.08.19 13:02 "Re: What's wrong with this TIFF?", by Helge Blischke
PostScript allows the direct inclusion of the binary CCITT Group IV data from a TIFF file. My program reads in a TIFF, converting it from multiple strips to a single strip, as necessary, and puts a PostScript wrapper around it. Generally things have worked well, but with certain images I'm getting a PostScript error in the middle of the TIFF data. The image was created in PaintShop Pro, then run through tiffcp to convert it to a single strip.
As far as I can tell, the content of the PostScript file and the TIFF file are identical.
GSView displays the PostScript properly. Distiller turns it into PDF. Acrobat reader displays and prints it properly. GSView blows up when trying to print it, giving this message (32% GSView Print):
Loaded Ghostscript DLL
Aladdin Ghostscript 5.50 (1998-9-11)
Copyright (C) 1998 Aladdin Enterprises, Menlo Park, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Unrecoverable error: ioerror in %image_file_continue
gsdll_execute_cont returns -12
Unrecoverable error: stackunderflow in exch
gsdll_exit returns 0
A zipped-up copy of the original TIF and the PostScript output (~4K) are available at ftp://ftp.quitt.net/PS/trouble.zip
First, the TIFF image is ok.
Second, your .ps file is not DSC compliant, what is necessary to be properly handled by GSView, as GSView prints pages or ranges of pages delimited by the appropriate DSC comments. I'd suggest the following imprevements to your PostScript code:
1a) Replace the %CCITTdata comment by a line
%%BeginData: nnnnnn binary bytes
where nnnnnn is the exact number of binary bytes following this comments.
1b) Append a newline (LF or CR or CRLF) to the binary data followed by a single comment line:
This will allow GSView to keep the binary image data together and to prevent it from inserting any comment lines in between - the "ioerror in %image_file_continue" indicates that the image operator didn't get as many data as needed, probably your do_image procedure exited on a comment line inserted by GSView.
2) - and this is not an essential improvement but would provide more page independence - you shouled use the dictionary variant of the image operator, as indicated below:
% ... beginning of ps code skipped
/image_save save def % bracket the image within save and restore
0 0 translate % or to what position you will put the image
/ImageMatrix [2550 0 0 -3300 0 3300]
/MultipleDataSources false % this is the default
/Decode [0 1] % you could invert the colors by [1 0]
/DataSource currentfile % see NOTE below
%%BeginData: nnnnnn binay bytes
--- insert the binary data here
If you want to prevent the image operator from consuming following PostScript code due to missing image data, you could add an additional filter like this at the point denoted by the NOTE comment above:
/DataSource currentfile 0 (%%EndData) /SubFileDecode filter
% rest as described above
This will preent the image operator to read beyond the %%EndData comment in any case.