[-valign={top|middle|bottom| above|below}] [-xoff=X] [-yoff=Y]
[-alpha=alpha-pgmfile] [-invert] [-opacity=opacity] [-linear] over-
lay_file [underlying_file [output_file]]

Minimum unique abbreviation of option is acceptable. You may use dou-
ble hyphens instead of single hyphen to denote options. You may use
white space in place of the equals sign to separate an option name
from its value.

This program is part of Netpbm.

pamcomp reads two images and produces a composite image with one of
the images overlayed on top of the other, possible translucently. The
images need not be the same size. The input and outputs are Netpbm
format image files.

In its simplest use, pamcomp simply places the image in the file over-
lay_file on top of the image in the file underlying_file, blocking out
the part of underlying_file beneath it.

If you add the -alpha option, then pamcomp uses the image in file
alpha-pgmfile as an alpha mask, which means it determines the level of
transparency of each point in the overlay image. The alpha mask must
have the same dimensions as the overlay image. In places where the
alpha mask defines the overlay image to be opaque, the composite out-
put contains only the contents of the overlay image; the underlying
image is totally blocked out. In places where the alpha mask defines
the overlay image to be transparent, the composite output contains
none of the overlay image; the underlying image shows through com-
pletely. In places where the alpha mask shows a value in between
opaque and transparent (translucence), the composite image contains a
mixture of the overlay image and the underlying image and the level of
translucence determines how much of each.

The alpha mask is a PGM file in which a white pixel represents opaque-
ness and a black pixel transparency. Anything in between is translu-
cent. (Like any Netpbm program, pamcomp will see a PBM file as if it
is PGM).

If the overlay image is a PAM image of tuple type RGB_ALPHA or
GRAYSCALE_ALPHA, then the overlay image contains transparency informa-
tion itself and pamcomp uses it the same way as the alpha mask
described above. If you supply both an overlay image that has trans-
parency information and an alpha mask, pamcomp multiplies the two
opacities to get the opacity of the overlay pixel.

Before Netpbm 10.25 (October 2004), pamcomp did not recognize the
transparency information in a PAM image -- it just ignored it. So
people had to make appropriate alpha masks in order to have a non-
opaque overlay. Some Netpbm programs that convert from image formats
such as PNG that contain transparency information are not able to cre-
ate RGB_ALPHA or GRAYSCALE_ALPHA PAM output, so you have to use the
old method -- extract the transparency information from the original
into a separate alpha mask and use that as input to pamcomp.

The output image is always of the same dimensions as the underlying
image. pamcomp uses only parts of the overlay image that fit within
the underlying image.

To specify where on the underlying image to place the overlay image,
use the -align, -valign, -xoff, and -yoff options. Without these
options, the default horizontal position is flush left and the default
vertical position is flush top.

The overlay image, in the position you specify, need not fit entirely
within the underlying image. pamcomp uses only the parts of the over-
lay image that appear above the underlying image. It is possible to
specify positioning such that none of the overlay image is over the
underlying image -- i.e. the overlay is out of frame. If you do that,
pamcomp issues a warning.

The overlay and underlying images may be of different formats (e.g.
overlaying a PBM text image over a full color PPM image) and have dif-
ferent maxvals. The output image has the more general of the two
input formats and a maxval that is the least common multiple the two
maxvals (or the maximum maxval allowable by the format, if the LCM is
more than that).









ppmmixand pnmpastearesimpler,lessgeneral versions of the same

ppmcolormaskand pbmmask,and pambackgroundcanhelpwith generat-
ing an alpha mask.

pnmcompisanolderprogramthat runs faster, but has less function.


pamcomp was new in Netpbm 10.21 (March 2004). Its predecessor, pnm-
comp, was one of the first programs added to Netpbm when the project
went global in 1993.

Copyright (C) 1992 by David Koblas (

netpbm documentation 17 July 2004 Pamcomp User Manual(0)