ppmforge
Convert images to portable pixmap format
TLDR
Generate an image of a planet
Generate an image of clouds or the night sky
Use a custom mesh size and dimension for fractal generation and specify the dimensions of the output
Control the tilt and the angle from which the generated planet is illuminated
SYNOPSIS
ppmforge [-x width] [-y height] [-s seed] [-l lambda] [-a attenuation] [-p palette] [-o outfile] [-g] [-m] [-q] [-e] [-v] [-d] [-t]
PARAMETERS
-x width
Specifies the width of the output image in pixels. Defaults to 256.
-y height
Specifies the height of the output image in pixels. Defaults to 256.
-s seed
Sets the random number generator seed. Useful for recreating specific landscapes.
-l lambda
Controls the 'roughness' or 'spikiness' of the terrain. A floating-point value between 0.0 and 1.0. Higher values create rougher landscapes. Defaults to 0.5.
-a attenuation
Controls how quickly the roughness decreases with resolution. A floating-point value between 0.0 and 1.0. Lower values make terrain features smaller at higher resolution. Defaults to 0.5.
-p palette
Selects one of 8 predefined color palettes (0-7) for the output image. Defaults to 0. Try different values to see varied color schemes.
-o outfile
Specifies the name of the output file. If omitted, the image is written to standard output (stdout).
-g
Generates a grayscale image (PGM format) instead of a color (PPM) image.
-m
Applies mirror boundary conditions to the fractal generation, which can affect the edges of the generated landscape.
-q
Quiet mode; suppresses progress messages to stderr.
-e
Forces the image dimensions to be even, which can sometimes improve rendering for certain algorithms.
-v
Verbose mode; prints the effective parameters used for generation to stderr.
-d
Debug mode; prints additional diagnostic information during execution.
-t
Test mode; used for internal testing, not generally for end-users.
DESCRIPTION
ppmforge is a command-line utility from the Netpbm suite that creates pseudo-random fractal landscapes. It uses a midpoint displacement algorithm to generate a topographical map, which is then rendered as a Portable Pixmap (PPM) image. Users can control various aspects of the generated landscape, including its dimensions, the 'roughness' or spikiness of the terrain (via the -l parameter), and how quickly this roughness diminishes at higher resolutions (via the -a parameter). The command also allows selection from several predefined color palettes, or generation of a grayscale image. The output is a raw PPM file, which can be further processed or converted using other Netpbm tools or image manipulation software. It's often used for generating background textures, heightmaps, or simply exploring fractal geometry.
CAVEATS
Generated images are in Netpbm's raw PPM or PGM format. You may need to use other Netpbm tools like ppmtogif, ppmtowebp, or pnmtopng, or external image editors (e.g., ImageMagick) to convert them to more common formats like PNG or JPEG. Generating very large images can consume significant memory and processing time. Experimentation with -l and -a parameters is often necessary to achieve desired visual effects.
FRACTAL GENERATION
ppmforge employs a variant of the midpoint displacement algorithm. This iterative process starts with a simple square and recursively subdivides it, offsetting the center point by a random amount. This offset is scaled down at each iteration, creating a fractal pattern. The lambda and attenuation parameters directly influence this scaling and randomness, allowing fine-grained control over the generated terrain's characteristics.
OUTPUT FORMAT
The primary output format is PPM (Portable Pixmap) or PGM (Portable Graymap) if the -g option is used. These are simple, uncompressed image formats often used as an intermediate step in image processing pipelines. PPM represents each pixel as a 3-byte RGB triplet, while PGM uses a single byte per pixel for grayscale. Netpbm's philosophy is to provide many small, specialized tools that can be chained together via pipes, making its formats ideal for inter-program communication.
HISTORY
ppmforge is part of the Netpbm project, a long-standing open-source package of graphics utilities for converting, manipulating, and viewing images in the Portable Pixmap (PPM), Portable Graymap (PGM), and Portable Bitmap (PBM) formats. The tool's underlying algorithm, midpoint displacement, is a classic technique for generating fractal terrains, originating in the early days of computer graphics.