Bug 689308 - Bounding box breaks on EPS-to-PDF conversion
Summary: Bounding box breaks on EPS-to-PDF conversion
Status: RESOLVED WONTFIX
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: master
Hardware: All All
: P4 normal
Assignee: Alex Cherepanov
URL: https://bugs.launchpad.net/ubuntu/+so...
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-28 04:43 UTC by Till Kamppeter
Modified: 2009-08-16 03:58 UTC (History)
4 users (show)

See Also:
Customer:
Word Size: ---


Attachments
patch (2.45 KB, patch)
2007-07-01 12:25 UTC, Alex Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2007-06-28 04:43:11 UTC
See this Ubuntu bug report:

https://bugs.launchpad.net/ubuntu/+source/ghostscript/+bug/42944

The EPS file attached there gets a wrong bounding box when converted to PDF. I
have tested with the HEAD of the subversion repository of Ghostscript and I can
reproduce the problem.
Comment 1 Alex Cherepanov 2007-06-28 05:49:55 UTC
Ghostscript already interprets the EPS bounding box comments
with -dEPSCrop command line option.

Probably, this option should be enabled by default for EPS files.
Comment 2 Ray Johnston 2007-06-28 08:24:34 UTC
If EPSCrop is to be enabled by default, then we need to change the gs_epsf
logic to allow it to accept -dEPSCrop=false

      //systemdict /EPSCrop known {
        EPSBoundingBoxCrop
      } {
        //systemdict /EPSFitPage known {
          EPSBoundingBoxFitPage
	} {
           ...
        } ifelse
      } ifelse

above would be problematic since if EPSCrop were the default, EPSFitPage would
never be looked at.
Comment 3 Till Kamppeter 2007-06-28 08:54:59 UTC
I think we should change this logic, as for usability -dEPSCrop should be the
default, as this is what users expect and users usually do not know about the
-dEPSCrop option.

Therefore I am reopening this.
Comment 4 Alex Cherepanov 2007-07-01 12:25:18 UTC
Created attachment 3103 [details]
patch

Change the default to cropping EPS to the bounding box. Drop EPSCrop option.
Add EPSPlace option to select backward-compatible behavior.

All EPS files in Comparefiles suite render to different page sizes.
Comment 5 Alex Cherepanov 2007-07-01 15:14:54 UTC
This is a full list of the files that renders differently.
They are all EPS files despite the .ps extension.

Bug687156.ps
Bug687546.ps
Bug687660.ps
Bug687984.eps
Bug688000.ps
Bug688327.ps
Bug688453.ps
Bug688822.eps
Bug688895.ps
Bug689269.ps
FIG3.eps
Type3FontTexture.ps
golfer.eps
muur.eps
ridt91.eps
tiger.eps
type3xshow.eps
Comment 6 Till Kamppeter 2007-07-02 02:54:35 UTC
Tested with the File attached to the Ubuntu bug report and it works.
Comment 7 Ray Johnston 2007-07-02 08:06:29 UTC
The EPSPlace option is not a very good option since it doesn't (at least
in English) associate with the action.

"Placing" is usually thought of as specifying the location of place (an object),
as in -sEPSPlace=123x456 to place an EPS origin at a specific place on the page.
Note the use of '-s' instead of -d to allow horizontal (X) and vertical (Y)
origin point since -d only allows a single value and we shouldn't rely on
extensions like -dEPSPlace=\[123\ 456\] since this won't work the same across
all platforms and shell implementations.

Alternatitvely, please consider -dEPSCrop=false or -dEPSNoCrop.
Comment 8 Marcos H. Woehrmann 2007-07-03 09:38:14 UTC
Just to make things more confusing I prefer -dNoEPSCrop
Comment 9 Ray Johnston 2007-07-03 09:44:26 UTC
Note that this will cause confusion if the requested command line PAPERSIZE
is also specified and is ignored now because -dEPSCrop is the default.

We have discussed this and think that if the command line option sets the
PAPERSIZE (or DEVICEWIDTH.../DEVICEHEIGHT) that EPSCrop should not occur
and override the page size (returning to the previous behavior)
Comment 10 Till Kamppeter 2007-07-03 10:01:19 UTC
So let "-dEPSCrop" only be the default if non of "-dNoEPSCrop",
"-sPAPERSIZE=...", or other options setting the page size are given.
Comment 11 Alex Cherepanov 2007-07-04 13:08:36 UTC
The PAPERSIZE option sets the initial page size. This size can be changed
by a setpagedevice operator. This behavior is not considered confusing.

So the question is: Can EPS change the page size? With EPSCrop option,
which is a proposed default, EPS can change paper size. EPSCrop option
existed before and nobody complained about the interaction with PAPERSIZE.

What PAPERSIZE comes from a script, or an environment variable and the user
is unaware of it. Suddenly, the default doesn't work. But what if we override
PAPERSIZE when -dEPSCrop is given explicitly ? Now, that's confusing.
Comment 12 William Bader 2007-07-12 04:44:14 UTC
EPS can not change the page size.  Conforming EPS files can not use the
setpagedevice operator or change the imageable area through statusdict or
userdict.  See Adobe document 5002, "Encapsulated PostScript File Format
Specification", Version 3.0, 1 May 1992, section 2.4 "Illegal and Restricted
Operators".
The size for the PDF should probably come from the BoundingBox comment with an
option to override it on the command line.
Comment 13 roucaries.bastien+bug 2009-08-13 05:43:33 UTC
Any news of this bug?
Comment 14 Ray Johnston 2009-08-15 16:55:24 UTC
Alex requested clarification of the options.

-sPAPSERSIZE= (or -dDEVICEWIDTHPOINTS= -dDEVICEHEIGHTPOINTS=) are defined as
setting a default paper (media) size that can be overridden by later PS
or PDF actions unless -dFIXEDMEDIA is also specified.

The -gWWWxHHH option sets the device width and height in pixels and is defined
to imply -dFIXEDMEDIA.

This is all documented in:
   http://www.artifex.com/gs-current-release/Use.htm#Paper_size
   http://www.artifex.com/gs-current-release/Use.htm#Page_parameters
and
   http://www.artifex.com/gs-current-release/Use.htm#Parameters

Note that the last reference should probably be moved since it is currently
in the 'Setting Parameters' section and should probably be in one of the
other two sections.

As far as the use of -dEPSCrop, my reading of:
   http://www.artifex.com/gs-current-release/Use.htm#EPS_parameters
is that this option allows the EPS file BoundingBox to automatically act like
a 'setpagedevice' that sets the PageSize and the initial graphics state
"translate" (using Install) accordingly.

Therefore, the -dEPSCrop should be ignored if -gwWWxHHH or -dFIXEDMEDIA was
set, otherwise it is allowed to override the default page/media size set
by other methods, including execution of a PS 'setpagedevice'. Thus using 
this option on other than a single EPS file will result in the page being
resized -- too bad, so sad.

The -dEPSCrop is only really useful for a single EPS file, not as a default
or general option since it might cause strange effects when a PS file 'runs'
an EPS file in order to "place" it.

Since EPSCrop is implemented in the "run" operator, I don't think it will
interefere with EPS files embedded with a PS file that is itself "run" so
that normal EPS placement in PS files should work OK.

IMHO, making -dEPSCrop the default is misleading and results in non-conforming
behavior. I think this bug should be closed as "WONTFIX" since changes will
change the documented behavior (that has been in place for YEARS).

As far as the original bug report, someone wanting to convert an EPS to a
PDF such that the EPS BBox will be the PDF MediaBox should use -dEPSCrop.
Others should not use this option.
Comment 15 Alex Cherepanov 2009-08-15 17:16:04 UTC
Ray, thank you for clarification.
I'm closing the bug as "WONTFIX".
Comment 16 James Cloos 2009-08-15 18:26:50 UTC
[Just a side note, while I’m in bug replying mode -JimC]

I can’t imaging *ever* wanting to run gs(1) myself (as opposed to how gv(1) et
al run it) on an eps file w/o cropping to the (intersection of the) bounding box
(with the physical display).

(Perhaps a *bit* larger than the physical display, but certainly less than twice
the physical display’s linear size.)

I think most users would agree.

For converting to pdf, I think *all* users would prefer that the eps’s bounding
box is used as the media box in the pdf.

It is just what people expect.
Comment 17 William Bader 2009-08-16 03:58:39 UTC
With conversion to PDF, would it matter if you were creating a PDF to print or a
PDF/X to pass to another application?