On 11-May-05 David Griffiths wrote: > Hi, I'm new to pic/groff and I've been having some problems > producing either gif or jpeg images using them. The basic > problem seems to be that pic/groff/postscript all have the > concept of a page that they are drawing on whereas I want the > resulting image to have all the whitespace cropped from the > margins. This is to go in a web page so the idea of a page > doesn't make sense.
A method which I have often used when using groff (e.g. with 'pic') to create a picture which I want to import as EPS is to simply edit the PostScript file. This, though not fast or automated, works fairly easily. First make your 1-page output in PS using groff. This will come out as suitable for printing on (e.g.) an A4 sheet. Then open the PS file in a PS viewer (I use 'gv' which can be set to re-read the file whenever it changes). Next, open the PS file in a text editor. Groff normally does not put a "%%BoundingBox:" line in the PS file, so the task is to put one in (or, if there is one there already, change it). The format of a ""BoundingBox:" line is %%BoundingBox: llx lly urx ury where llx lly urx ury are four numbers (giving the X and Y coordinates, in points, of the bottom left and top right corners of the page). You will need one of these (preferably at the head of the file amongst all the other "%%" lines you will see there). 'gv' also has a useful little window which shows the (X,Y) coordinates, in points, of the position of the mouse pointer as you move it around; so you can read off suitable values from this window, and this may be all you need to do. Having established in this way what should be reasonable values for llx, lly, urx and ury, insert a "%%BoundingBox:" line of the above form into the PS file, and get 'gv' to re-read it. It should now display solely that part of the page that lies within the BoundingBox. If you're not satisfied, edit the llx, lly, urx, ury until you are. The result is then an EPS file which can be imported into another document, or converted using any standard image format comversion program (I usually use the 'convert' program from the ImageMagick suite, but the GIMP will also do it nicely, for instance). E.g. convert imagefile.ps imagefile.gif or convert imagefile.ps imagefile.jpg The resulting image file will have the dimensions of the BoundingBox. Note: that when importing/viewing/rendering an EPS file, the BoundingBox is a "clipping path" -- anything that lies outside it will not be printed/displayed[*]. This also applies to the conversion into other formats (as above): those .gif or .jpg files will include only those parts of the original which lay within the BB. [*] You can over-ride this in 'gv' which, by default, displys an EPS file in "BoundingBox" mode, as you can verify by seeing "BBox" in the page-format window. If you change this to say "A4" using the drop-down menu, then you will see the whole original. Another resource which can also be used to create an EPS file which includes on the marks on the page is "ps2epsi" (part of ghostscript). This also creates a large "ESPI header" in the output file which is a hex-encoding of a binary bitmap of the page. For the sake of simply having an EPS file for later conversion, you can safely delete all of that stuff (it appears as a large block of "%%...." lines near the top of the file). You could also examine the code in ps2epsi and ps2epsi.ps to create new files, say pstoepsi and pstepsi.ps which do not produce this EPSI block. One disadvantage I have found with ps2epsi is that it uses ghostscripts notion of thr font metrics, which may not agree with those used in the groff file, with the result that you may get parts of letters (e.g. descenders) clipped off. Again, I have edited the ghostscript scripts to allow a little extra margin so as to avoid this, but I find that the BoundingBox method described above is better, as well as being more flexible (e.g. you can use it to cut out just the part of the page you want as a separate image file). Hoping this helps, Ted. The disadva -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 11-May-05 Time: 16:20:42 ------------------------------ XFMail ------------------------------ _______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff