Converting Molscript labels to Raster3D
The most frequent question I get about Raster3D is "How can I get the labels
from Molscript into my Raster3D picture?".
There is now a very easy answer - "Install Molscript Version 2!"
The newer Molscript version (available via the web from
draws labels in such a way that they will simply appear in your Raster3D
image along with everything else.
The rest of this information is therefore now obsolete, at least with regard
to Molscript. It may, however, be useful as an example of how to mix
PostScript and Raster3D processing. Generally this requires more effort than
the result is worth.
I recommend simply labelling your Raster3D output image using an interactive
annotation tool on a workstation screen (e.g. the annotate mode of
ImageMagick's display program). However, for anyone bound and determined to
use Molscript for labelling I will describe how it can be done.
- The first thing to do is to establish the size of your eventual image in
pixels. Let us say that you want a 3-inch by 2-inch print to be produced on
a 300 dpi dye sublimation printer. 300 dpi (dots per inch) times the
desired size gives 900x600 pixels for the image size. Construct a header
file for the render program which describes this image size; e.g.
My new picture with no anti-aliasing
45 30 NTX,NTY number of tiles in x, y
20 20 NPX,NPY number of pixels per tile
1 anti-aliasing scheme 1 (none) or 4 (smoothed)
0 0 0 black background
Pay particular attention to the fact (yes, it's confusing) that if you use
anti-aliasing schemes 2 or 3 then the eventual number of pixels is not
simply the product NTX*NPX,NTY*NPY. This is explained in the render manual.
- Now make sure that your Molscript input file is actually drawing in a box
of the shape you have just described. To use the procedure I describe below,
you must use the "area" command of Molscript to force the
lower left corner to (0,0) and the upper right corner to (900,600). Furthermore
there must be no bordering frame drawn around the image. So your Molscript
input file will begin:
area 0. 0. 900. 600. ;
background black ;
- Run Molscript with the -raster3d option to produce an input file to render
which uses the header you constructed in step 1.
molscript -r < picture.mol | render | convert avs:- picture.ppm
- Edit the molscript file to remove or comment out all drawing commands
except for the labels. Run molscript again, this time in PostScript mode,
to produce a PostScript file containing only the labels.
molscript < picture_labels.mol > labels.ps
- Use ghostscript to convert the PostScript file into a raster image exactly
the same size as your Raster3D image.
gs -sDEVICE=ppm -sOutputFile=labels.ppm -g900x600 labels.ps
At this point you have two images:
picture.ppm 900x600 Raster3D image from original Molscript file
labels.ppm 900x600 image containing only the labels
- Use the combine program from ImageMagick to draw the labels on top of the
combine -compose atop labels.ppm picture.ppm pic+labels.ppm
- I used the ppm raster file format throughout this example just because
it works in both ImageMagick and ghostscript. This may be installation
dependent, however. I'll now convert it back to a TIFF file.
convert pic+labels.ppm beautiful.tiff
As you see, this is a rather lengthy procedure. Furthermore, the label
positioning will be slightly off compared to the pure PostScript version
because Raster3D and Molscript treat perspective differently. As I say,
I prefer to just type in the labels interactively so that I can see where
they are going.