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
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.
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).
Created attachment 3556 [details] screenshot.png
Created attachment 3557 [details] screenshot.png
Created attachment 3558 [details] screenshot.png
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).
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.
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<<
*** This bug has been marked as a duplicate of 689562 ***