Home / Alt manpages / ppmbrighten(1)

  • ppmbrighten(1)
  • User command
  • linux

Brighten Images with pambrighten Instead of ppmbrighten

ppmbrighten still runs fine, but it is obsolete, and knowing how it differs from its replacement saves you a subtly wrong pipeline. On this machine the installed package is Netpbm 11.05.02-1.1build1. Allow about fifteen minutes if the input image is already available.

Since Netpbm 10.86, the supported command is pambrighten. The older ppmbrighten stays useful in scripts that expect its historical behaviour, but its name hides two compatibility details: it always writes PPM, and its normalisation path is not the same as the replacement's options.

1. Check the Installed Commands

Start with read-only checks. Brightening an image normally needs no elevated privilege, only read access to the input directory and write access to the destination:

$ command -v ppmbrighten pambrighten pnmnorm ppmtoppm
/usr/bin/ppmbrighten
/usr/bin/pambrighten
/usr/bin/pnmnorm
/usr/bin/ppmtoppm
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1
$ ppmbrighten --help
pambrighten: Use 'man pambrighten' for help.

That help response is a useful clue: this installation implements ppmbrighten through the newer program. Do not treat the package version above as universal. Record the version on the host where a script will actually run, especially if you depend on output format.

2. Make a Test Copy Before Changing the Image

Choose a separate destination while testing. Shell redirection with > truncates an existing destination before the converter has even proved it can read the input. These commands preserve the input and write a new file:

$ INPUT=/path/to/input.ppm
$ OUTPUT=/path/to/input-bright.ppm
$ test -r "$INPUT"
$ ppmbrighten -value=50 "$INPUT" > "$OUTPUT.new"
$ test -s "$OUTPUT.new"
$ mv -- "$OUTPUT.new" "$OUTPUT"
$ file "$OUTPUT"
/path/to/input-bright.ppm: Netpbm image data, ... pixmap

The -value=50 option asks for a 50 per cent increase in HSV Value, not a fixed number of RGB levels. A pixel already at maximum Value clips to full Value, so the brightest areas cannot go past what the format allows. Keep the original until you have inspected the new image.

Warning

If conversion fails, do not run the mv command. Remove the incomplete temporary file only after checking its name:

$ ls -l -- "$OUTPUT.new"
$ rm -- "$OUTPUT.new"
$ test -f "$OUTPUT" && echo 'previous output remains'

That final removal is destructive. It is safe here only because the old output has a different name and the input remains untouched.

3. Adjust Brightness and Saturation Deliberately

pambrighten works in HSV colour space: Value controls brightness, Saturation controls how far a colour sits from grey. Each option takes a percentage, positive or negative, with both defaulting to zero.

$ pambrighten -value=100 "$INPUT" > "$OUTPUT.new"
$ pambrighten -saturation=+100 -value=-50 "$INPUT" > "$OUTPUT.new"
$ pambrighten -saturation=-25 "$INPUT" > "$OUTPUT.new"
  • The first example doubles Value.
  • The second doubles Saturation while halving Value.
  • The third reduces Saturation, which generally makes colours less vivid.

Run one command at a time while deciding what you want. If an increase would exceed the full HSV range, Netpbm caps that component rather than producing a value outside the image format.

The same options work with the compatibility name:

$ ppmbrighten -value=100 "$INPUT" > "$OUTPUT.new"
$ head -c 2 "$OUTPUT.new"
P6

The output starts with P6 on this installation because ppmbrighten always produces PPM, even when the input was another Netpbm format. Do not read the binary pixel data in a terminal: use file or an image viewer once the command exits successfully.

4. Prefer pambrighten for New Scripts

For new work, call pambrighten directly. It accepts the range of Netpbm image formats the installed release supports and normally preserves the input format. Extra channels, such as a transparency channel in a PAM image, pass through unchanged, which makes it the better default when a pipeline should not silently convert every image to PPM.

$ pambrighten -value=50 "$INPUT" > "$OUTPUT.new"
$ file "$OUTPUT.new"
/path/to/input-bright.new: Netpbm image data, ...

The exact wording from file depends on the input and the installed file utility, so check the format and dimensions rather than matching the whole sentence in a script. If a downstream program specifically requires PPM, convert the replacement's output as a separate, visible step:

$ pambrighten -value=50 "$INPUT" | ppmtoppm > "$OUTPUT.new"
$ head -c 2 "$OUTPUT.new"
P6

That explicit conversion is the practical difference between the two command names. With pambrighten, the brightening step preserves the input kind; ppmtoppm then makes the PPM requirement obvious to anyone reading the pipeline.

5. Handle Normalisation as a Separate Decision

The old command has a -normalize compatibility feature. The current pambrighten interface does not provide it. To remap the input's Value range before brightening, run pnmnorm first and pass its output to pambrighten:

$ pnmnorm "$INPUT" | pambrighten -value=25 > "$OUTPUT.new"
$ test -s "$OUTPUT.new"
$ mv -- "$OUTPUT.new" "$OUTPUT"
$ file "$OUTPUT"
/path/to/input-bright.ppm: Netpbm image data, ... pixmap

Normalisation changes the tonal range before the brightness adjustment. It can make an image look harsher by stretching its darkest and lightest values, so inspect the result rather than adding it automatically to every pipeline. If you need PPM output from a non-PPM input, make that contract explicit:

$ pnmnorm "$INPUT" | pambrighten -value=25 | ppmtoppm > "$OUTPUT.new"
$ head -c 2 "$OUTPUT.new"
P6

6. Diagnose the Usual Failures

A non-zero exit status means the pipeline did not complete successfully. Check the input path, permissions and temporary destination before changing options:

$ test -r "$INPUT" || echo 'input is missing or unreadable'
$ ls -l -- "$INPUT"
$ printf 'status: %s\n' "$?"

The status printed above belongs to ls, so capture a converter's status immediately when scripting. With a pipeline, the shell may report only the last command's status unless you enable pipeline failure handling:

set -o pipefail
if pnmnorm -- "$INPUT" | pambrighten -value=25 > "$OUTPUT.new"; then
    mv -- "$OUTPUT.new" "$OUTPUT"
else
    status=$?
    printf 'image pipeline failed with status %s\n' "$status" >&2
    rm -- "$OUTPUT.new"
    exit "$status"
fi

Do not add sudo to an ordinary conversion. Elevated privileges do not repair a malformed image or a wrong option, and they can leave root-owned output behind. Use them only when file permissions genuinely require it, after checking the destination will stay manageable by the account that normally processes the images.

Done means

  • You confirmed the installed Netpbm version and the four commands the workflow uses.
  • You understand ppmbrighten is obsolete and always writes PPM.
  • New scripts use pambrighten when preserving the input format matters.
  • Brightness and saturation changes use explicit percentages and a separate output file.
  • Normalisation, when needed, runs through pnmnorm first, before brightening.
  • The original image stays available until the converted result has been checked.