Skip to content

g.pnmcomp

Overlays multiple PPM image files.

g.pnmcomp input=name [,name,...] [mask=name [,name,...]] [opacity=float [,float,...]] output=name [output_mask=name] width=integer height=integer [bgcolor=name] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

g.pnmcomp input=name output=name width=integer height=integer

grass.script.run_command("g.pnmcomp", input, mask=None, opacity=None, output, output_mask=None, width, height, bgcolor=None, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("g.pnmcomp", input="name", output="name", width=integer, height=integer)

Parameters

input=name [,name,...] [required]
    Name of input file(s)
mask=name [,name,...]
    Name of input mask file(s)
opacity=float [,float,...]
    Layer opacities
output=name [required]
    Name for output file
output_mask=name
    Name for output mask file
width=integer [required]
    Image width
height=integer [required]
    Image height
bgcolor=name
    Background color
    Either a standard color name or R:G:B triplet
--overwrite
    Allow output files to overwrite existing files
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

input : str | list[str], required
    Name of input file(s)
    Used as: input, file, name
mask : str | list[str], optional
    Name of input mask file(s)
    Used as: input, file, name
opacity : float | list[float] | str, optional
    Layer opacities
output : str, required
    Name for output file
    Used as: output, file, name
output_mask : str, optional
    Name for output mask file
    Used as: output, file, name
width : int, required
    Image width
height : int, required
    Image height
bgcolor : str, optional
    Background color
    Either a standard color name or R:G:B triplet
    Used as: input, color, name
overwrite: bool, optional
    Allow output files to overwrite existing files
    Default: False
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

g.pnmcomp isn't meant for end users. It's an internal tool for use by wxGUI.

In essence, g.pnmcomp generates a PPM image by overlaying a series of PPM/PGM pairs (PPM = RGB image, PGM = alpha channel).

NOTES

The intention is that d.* modules will emit PPM/PGM pairs (by way of the PNG-driver code being integrated into Display Library). The GUI will manage a set of layers; each layer consists of the data necessary to generate a PPM/PGM pair. Whenever the layer "stack" changes (by adding, removing, hiding, showing or re-ordering layers), the GUI will render any layers for which it doesn't already have the PPM/PGM pair, then re-run g.pnmcomp to generate the final image (just redoing the composition is a lot faster than redrawing everything).

A C/C++ GUI would either have g.pnmcomp's functionality (image composition) built-in, or would use the system's graphics API to perform composition (for translucent layers, you would need OpenGL or the Render extension, or something else which supports translucent rendering).

Tk doesn't support transparent (masked) true-colour images (it does support transparent GIFs, but that's limited to 256 colours), and an image composition routine in Tcl would be unacceptably slow, hence the existence of g.pnmcomp.

SEE ALSO

g.cairocomp

AUTHOR

Glynn Clements

SOURCE CODE

Available at: g.pnmcomp source code (history)
Latest change: Friday Feb 07 19:16:09 2025 in commit a82a39f