Bug 689548 - bbox gives wrong values
Summary: bbox gives wrong values
Status: RESOLVED DUPLICATE of bug 689562
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Other Driver (show other bugs)
Version: master
Hardware: PC Linux
: P4 normal
Assignee: Marcos H. Woehrmann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-04 10:19 UTC by Jaime Villate
Modified: 2007-12-13 12:55 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
screenshot.png (5.66 KB, image/png)
2007-11-13 22:39 UTC, Marcos H. Woehrmann
Details
screenshot.png (5.66 KB, image/png)
2007-11-13 22:40 UTC, Marcos H. Woehrmann
Details
screenshot.png (8.11 KB, image/png)
2007-11-13 22:41 UTC, Marcos H. Woehrmann
Details
screenshot.png (8.10 KB, image/png)
2007-11-13 22:48 UTC, Marcos H. Woehrmann
Details
Another test case for head (r8363). Please check. (186 bytes, application/postscript)
2007-11-14 06:10 UTC, Jaime Villate
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaime Villate 2007-11-04 10:19:36 UTC
System: Ubuntu GNU/Linux 7.10
Ghostscript version: 8.61

The following command:
  gs -sDEVICE=bbox -dNOPAUSE -dBATCH example.ps 
gives a wrong value for the bounding box (the content of example.ps is appended
below):

GPL Ghostscript SVN PRE-RELEASE 8.61 (2007-08-02)
Copyright (C) 2007 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-ReguItal font from
/var/lib/defoma/gs.d/dirs/fonts/n021023l.pfb... 2746992 1322086 1963864 653050 1
done.
Loading NimbusRomNo9L-Regu font from
/var/lib/defoma/gs.d/dirs/fonts/n021003l.pfb... 2924424 1514055 1963864 653835 1
done.
%%BoundingBox: 65 99 267 161
%%HiResBoundingBox: 65.465998 99.499005 266.003992 160.492987

--------------------------------------------------------------------
Contents of file example.ps:

%!PS-Adobe-2.0
%%Title: example.ps
%%Date: Sat Nov  3 20:58:13 WET 2007
%%BoundingBox: 52 97 267 163
%%Page: 1 1
0.8 0 0 setrgbcolor 1 setlinewidth
100 15 160 {100 exch moveto 120 0 rlineto stroke} for
0 setgray 0.3 setlinewidth newpath
140 130 3 0 360 arc gsave 0.7 0.6 0 setrgbcolor fill grestore stroke
/Times-Italic findfont 12 scalefont setfont
136 138 moveto (q) show
 55 127 moveto (V ) show currentpoint
225 127 moveto (V ) show
/Times-Roman findfont 12 scalefont setfont
(menor) show moveto (maior) show
showpage
Comment 1 Ray Johnston 2007-11-13 10:13:21 UTC
Ghostscript actually measures the bbox from the image. 
 
One thing that can affect the bbox is the fonts used. 
 
Just looking at the %%BoundingBox in the source file is not a good way to tell what the 
real bbox is. 
Comment 2 Marcos H. Woehrmann 2007-11-13 22:39:16 UTC
Even taking Comment #1 into account the bounding box is not correct.   With
gshead (r8363) I get a slightly different result:

% bin/gs -sDEVICE=bbox 689548.ps

%%BoundingBox: 55 99 267 161
%%HiResBoundingBox: 55.835998 99.499005 266.003992 160.492987

However, by adding "55 99 267 161 rectstroke" to the file before the showpage we
can see the top and right of the bounding box is still incorrect (see
screenshot.png, attached).
Comment 3 Marcos H. Woehrmann 2007-11-13 22:39:47 UTC
Created attachment 3556 [details]
screenshot.png
Comment 4 Marcos H. Woehrmann 2007-11-13 22:40:55 UTC
Created attachment 3557 [details]
screenshot.png
Comment 5 Marcos H. Woehrmann 2007-11-13 22:41:40 UTC
Created attachment 3558 [details]
screenshot.png
Comment 6 Marcos H. Woehrmann 2007-11-13 22:48:25 UTC
Created attachment 3559 [details]
screenshot.png

Please ignore comment #2.  I was confused as to how rectstroke works, it takes
x,y,width,height, not x1,y1,x2,y2.  The correct line to add is:

55 99 212 62 rectstroke

Which produces a reasonable bounding (see screenshot.png, attached).
Comment 7 Jaime Villate 2007-11-14 06:10:07 UTC
Created attachment 3560 [details]
Another test case for head (r8363). Please check.

Marcos: does that mean that the bug has been fixed in a version after 8.61? To
which version should a upgrade to avoid the bug?
Since I cannot try the HEAD (r8363) version, I'm sending you a simpler test
case, which gives a bounding box
%%BoundingBox: 0 0 0 0
in gs 8.61, while it gave the correct value in gs 8.01:
%%BoundingBox: 199 498 321 560

Ray: I was not looking at the values in %%BoundingBox in the file but at the
vaues in the image, as shown by gv. Even without using any fonts, the problem
remains, as you can see in the attached file, which gives an empty bounding box
in ghostscript 8.61.
Comment 8 Marcos H. Woehrmann 2007-11-14 07:20:34 UTC
gshead (r8363) gives the correct results:

marcos@amd64:[49]% gshead -sDEVICE=bbox ./689548.ps 
GPL Ghostscript SVN PRE-RELEASE 8.61 (2007-08-02)
Copyright (C) 2007 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
%%BoundingBox: 199 498 321 561
%%HiResBoundingBox: 199.997994 498.401985 320.003990 560.015983
>>showpage, press <return> to continue<<

Comment 9 Marcos H. Woehrmann 2007-11-14 07:25:59 UTC

*** This bug has been marked as a duplicate of 689562 ***