Bug 687915

Summary: -dEPSCrop doesn't work if %%BoundingBox (atend)
Product: Ghostscript Reporter: david
Component: PS InterpreterAssignee: Ken Sharp <ken.sharp>
Status: RESOLVED WONTFIX    
Severity: enhancement CC: christinedelight.top85, gsview, jackie.rosen, ray.johnston, remko, shailesh.mistry
Priority: P4 Keywords: bountiable
Version: 8.15   
Hardware: PC   
OS: Windows 2000   
Customer: Word Size: ---
Attachments: An EPS file made using xmgr/Grace with bounding box (atend)

Description david 2005-01-27 05:55:23 UTC
Cropping to the bounding box of an EPSF file doesn't seem to work if the 
bounding box is in the trailer (e.g., in a file made using Grace/Xmgr).

The appropriate bounding box parsing code seems to be in lib/gs_epsf.ps but as 
I'm no whiz at PostScript I've been unable to fix this locally.

GSView deals with cropping in its own way.

Hope this makes sense.

David
Comment 1 Jack Moffitt 2005-02-02 07:37:37 UTC
We'll need the EPS file in question as well as the Ghostscript commandline that
you are using in order to reproduce this problem.  Please attach them.
Comment 2 david 2005-02-02 09:04:16 UTC
Created attachment 1187 [details]
An EPS file made using xmgr/Grace with bounding box (atend)

The command line used to convert is the following

"C:\Program Files\Ghostscript\gs8.15\bin\gswin32c" -sDEVICE=png16m -dEPSCrop
-sOutputFile=t2.png -- "t2.eps"

Hope this helps

David
Comment 3 Ray Johnston 2005-02-02 09:43:57 UTC
This appears to be legal EPS and we would need to search for the
%%Trailer: comment.

If the file is not positionable, then we would need to copy the input
to a temp file so we can position to the end and search for the
Trailer and BBox data.

We are marking this bountiable.
Comment 4 Ralph Giles 2005-02-02 12:27:24 UTC
Ghostgum pointed out that this limitation is documented in Use.htm
Comment 5 Russell Lang 2005-03-30 16:15:28 UTC
I'm working on a solution to this.  Current implementation peeks for
%%BoundingBox in the first 1000 bytes.  If found, it assumes that %%BoundingBox
is in the header and uses current code.  Otherwise, it copies the EPS to a
temporary file while parsing for DSC comments.  At the end, it will grab the
correct %%BoundingBox (either head or trailer as per DSC specification) and use
that.  The PS interface to the DSC parser appears to require an additional
operator to copy information from the DSC struture to the DSC dictionary.

Comment 6 Russell Lang 2005-04-04 06:21:27 UTC
Fix submitted to code review
  http://ghostscript.com/pipermail/gs-code-review/2005-April/004771.html
Comment 7 Alex Cherepanov 2008-08-20 18:54:54 UTC
*** Bug 690034 has been marked as a duplicate of this bug. ***
Comment 8 Russell Lang 2008-08-20 22:58:48 UTC
There is no activity on this bug.  The code was not reviewed, and will no longer
apply due to a patch to fix another bug (ignored HiResBoundingBox).  Note that
the fix below made it trivial to handle HiResBoundingBox correctly.
Comment 9 Ray Johnston 2008-08-21 08:14:13 UTC
Reassigning to Alex to fix (possibly by fixing the patch from Russell).
Comment 10 Shailesh Mistry 2011-07-13 20:51:00 UTC
Bug still reproducible in Ghostscript 9.03
Comment 11 Ken Sharp 2013-10-14 00:29:58 UTC
I'm closing this due to lack of activity, and because Russell says his patch won't work (comment #8). I can't identify which other change caused it not to work.

My apologies to Russell that this was allowed to go unreviewed for so long that it became unusable.