2 Using PSMERGE

 2.1 Combining Images
 2.2 Scaling, rotating and shifting images
 2.3 Complex combinations
 2.4 Summary of PSMERGE switches

The psmerge program writes its output to the standard output channel (stdout). This can be redirected to a file or piped straight to a printer queue; e.g.:

  % psmerge picture.eps > printme.ps

or

  % psmerge picture.eps | lpr -Pps_printer

The examples above simply converts an EPS file to a normal PostScript file, the only difference being that the normal PostScript file shifts the picture origin to the bottom left corner of the printable area on the printer. This is useful because if an EPS file is printed without conversion, the picture origin will be at the bottom left corner of the paper and on most printers this means that the bottom and left edges will lie outside the printable area and will be invisible.

2.1 Combining Images

The principle use of PSMERGE is to combine more than one EPS file into a single picture. For example:

  % psmerge pic1.eps pic2.eps > printme.ps

will overlay the two pictures with their origins at the same place on the paper.

For line graphics and text the order of the files does not make any difference but if either picture contains filled areas or grey scale images it does. Filled areas and grey scales are opaque and will obliterate anything already plotted in the same region of the page. Therefore, for example, to overlay a contour map on a grey scale image, the file containing the contour map must appear after the one containing the image.

2.2 Scaling, rotating and shifting images

Pictures can be scaled, translated (shifted) and rotated. For example:

  % psmerge -s0.5x0.5 -t72x144 -r10 pic1.eps > printme.ps

will shrink the picture to half its normal size, move the origin 1 inch to the right and 2 inches upwards and rotate it 10 degrees anti-clockwise.

Translations are in units of 1/72 of an inch1 and rotations are in degrees anti-clockwise.

2.3 Complex combinations

PSMERGE applies transformations are applied in the order that they appear on the command line and are cumulative, so that, for example, -r45 -r45 is equivalent to -r90 but -t72x72 -s2x2 does not have the same effect as -s2x2 -t72x72.

After each EPS file is processed the scaling factors are reset to unity and the translation and rotations reset to zero. The following example takes two A4 landscape pictures and pastes them one above the other on a single A4 page in portrait orientation:

  % psmerge -s0.707x0.707 -r90 -t550x396 pic1.eps \
         -s0.707x0.707 -r90 -t550x0 pic2.eps > printme.ps

If -e appears on the command line anywhere, the output file will be another EPS file rather than normal PostScript. This allows files to be processed by PSMERGE more than once in a pipeline using the special file name - (hyphen) which means “use the standard input as the input file”. Therefore, the same effect as the previous example can be achieved with the following command:

  % psmerge -e -t0x560 pic1.eps pic2.eps | \
         psmerge -s0.707x0.707 -r90 -t550x0 - > printme.ps

Instead of scaling each picture and positioning it on the page independently, the two pictures are combined into one and then this single picture rotated and scaled.

The operation could be performed in two steps with the output from the first stored in a temporary file:

  % psmerge -e -t0x560 pic1.eps pic2.eps > temp.eps
  % psmerge -s0.707x0.707 -r90 -t550x0 temp.eps > printme.ps

2.4 Summary of PSMERGE switches

The PSMERGE program uses the following command switches:

-e
: produce Encapsulated PostScript rather than PostScript.
-rN
: rotate N degrees anti-clockwise.
-sMxN
: scale image by factor M in X direction and N in Y direction.
-tMxN
: translate (shift) image M points in X direction andN points in Y direction.

11/72 of an inch is sometimes referred to as a PostScript point and is the default unit for PostScript commands.