Received: by smtp02.oce.nl (4.1/SMI-4.1)
	id AA00750; Thu, 19 Aug 99 15:43:01 +0200
Received: from gate7.olympiakos.com ([207.113.13.68])
	by oce.nl (8.9.0/8.9.0) with ESMTP id PAA19504;
	Thu, 19 Aug 1999 15:33:36 +0200 (MET DST)
Received: from localhost (bin@localhost)
	by gate7.olympiakos.com (8.8.7/8.8.7) with SMTP id JAA15510;
	Thu, 19 Aug 1999 09:03:59 -0400
Received: by gate7.olympiakos.com (bulk_mailer v1.9); Thu, 19 Aug 1999 09:02:43 -0400
Received: (from majordom@localhost)
	by gate7.olympiakos.com (8.8.7/8.8.7) id JAA15499
	for tiff-outgoing; Thu, 19 Aug 1999 09:02:43 -0400
X-Authentication-Warning: gate7.olympiakos.com: majordom set sender to owner-tiff@olympiakos.com using -f
Received: from srz-berlin.de (ns.srz-berlin.de [212.5.11.1])
	by gate7.olympiakos.com (8.8.7/8.8.7) with ESMTP id JAA15496
	for <tiff@olympiakos.com>; Thu, 19 Aug 1999 09:02:39 -0400
Received: from SunFrame1 (gw.srz-berlin.de [212.5.11.2])
	by srz-berlin.de (8.8.7/8.8.7) with SMTP id PAA14071;
	Thu, 19 Aug 1999 15:02:26 +0200
Message-Id: <37BC0062.6168@srz-berlin.de>
Date: Thu, 19 Aug 1999 15:02:26 +0200
From: Helge Blischke <H.Blischke@srz-berlin.de>
Organization: SRZ BERLIN
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4m)
Mime-Version: 1.0
To: "Kevin D. Quitt" <Kevin@Quitt.net>
Cc: tiff@olympiakos.com
Subject: Re: What's wrong with this TIFF?
References: <Chameleon.935007858.Kevin@quitt>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-tiff@olympiakos.com

Kevin D. Quitt wrote:
> 
> 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):
> 
> Loading F:\gstools\gs5.50\gsdll32.dll
> 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
> Operand stack:
>     --nostringval--
> gsdll_exit returns 0
> Unloaded GSDLL
> 
> A zipped-up copy of the original TIF and the PostScript output (~4K) are
> available at ftp://ftp.quitt.net/PS/trouble.zip
> 
> Any and all help would be appreciated.
Kevin,
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:
    %%EndData

    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:
---snip---
% ... 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
<<
  /ImageType 1
  /Width 2550
  /Height 3300
  /ImageMatrix [2550 0 0 -3300 0 3300]
  /MultipleDataSources false % this is the default
  /BitsPerComponent 1
  /Decode [0 1] % you could invert the colors by [1 0]
  /DataSource currentfile  % see NOTE below
		<<
		  /Uncompressed false
		  /K -1
		  /EndOfLine false
		  /EncodedByteAlign false
		  /Columns 2550
		  /Rows 3300
		  /EndOfBlock false
		  /BlackIs1 false
		>>
     /CCITTFaxDecode filter
>>
%%BeginData: nnnnnn binay bytes
image
--- insert the binary data here
%%EndData
--- snip---
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.

Good luck

Helge


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