TIFF and LibTiff Mail List Archive

2001.03.19 18:05 "Bug in tiff2ps", by Bruce A. Mallett

I think that I've just found two bugs in tiff2ps.c.

Bug # 1 - flushing the ASCII85 image stream fails:

When output of ASCII85 format the current program puts out a line as follows:

        im_stream flushfile

to ensure that the current "hunk" of image data has been read to EOF (marked by the sequence "~>").

However the last time through the loop the image operator has completed rendering all of the image file and has therefore closed im_stream. The flushfile operator then fails (as shown below for ghostscript):

GNU Ghostscript 5.50 (2000-2-13)
Copyright (C) 1998 Aladdin Enterprises, Menlo Park, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file COPYING for details.
Error: /invalidaccess in --flushfile--
Operand stack:
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   2   3
%oparray_pop   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   .runexec2   --nostringval--
--nostringval--   --nostringval--   2   %stopped_push   --nostringval--   0   --nostringval--   %repeat_continue   --nostringval--
--nostringval--   --nostringval--
Dictionary stack:
   --dict:903/941(G)--   --dict:0/20(G)--   --dict:50/200(L)--   --dict:3/100(L)--
Current allocation mode is local
Current file position is 17722309

I've corrected line 841 of tiff2ps.c (your line number may be different since this is in my modified copy) to now output:

    im_stream status { im_stream flushfile } if

Thus I've changed line 841 to now read:

  fputs(" im_stream status { im_stream flushfile } if\n", fd);

Its prior value was:

  fputs(" im_stream flushfile\n", fd);

Bug # 2 - no PS L2 CMYK support

Perhaps this is not a bug but rather just a "not implemented yet". However when a TIFF file having four samples per pixel is encountered the routine

    "PS_Lvl2colorspace(FILE* fd, TIFF* tif)"

(on or about line 504) would blindly set the colorspace to RGB. I've modified this routine to output:

    /DeviceCMYK setcolorspace

to fix this. In addition I modified the routine to base this decision on the setting of "photometric" using one of the defined PHOTOMETRIC_* values rather than the samplesperpixel as it had previously been based upon.

Note to Mr. Warmerdam:

Perhaps it would be better to wait on the changes (imagemask and pixel interpolation) that I e-mailed you last week and not put them in the CVS tree. I'll run with these additional changes for a week or so and send you another update iff things look A-ok.

- Bruce