Home / Alt manpages / palmtopnm(1)

  • palmtopnm(1)
  • User command
  • linux

Convert Palm Bitmaps to PPM with palmtopnm

You will finish with a PPM image converted from a Palm Bitmap, plus a safe way to check whether the source contains a transparent colour. This guide uses Netpbm 11.5.2 from the installed netpbm package. Allow about ten minutes if you already have a Palm Bitmap, or longer if you first need to locate one.

palmtopnm reads a Palm Bitmap from a named file or standard input and writes a PPM image to standard output. The command is an ordinary user-level conversion: the examples do not need sudo, and they do not modify the input file.

1. Confirm the installed command

Check which executable will run and record the local Netpbm build information:

$ command -v palmtopnm
/usr/bin/palmtopnm
$ palmtopnm --version
palmtopnm: Using libnetpbm from Netpbm Version: Netpbm 11.5.2

The version output also includes build details. Exact diagnostic wording can vary, but the important check is that the command is the expected Netpbm program. If command -v returns nothing, install the distribution's Netpbm package through its normal package-management process before continuing. That is the only step here that changes system state, and it requires the privileges appropriate to your distribution.

Checkpoint

You should have a readable source path such as /path/to/bitmap.palm. Do not replace that placeholder with a path until you have checked that the file exists and is the intended input.

2. Convert one Palm Bitmap

Write the converted image to a new file. The redirection is important: without it, binary PPM data is sent to your terminal.

$ test -r /path/to/bitmap.palm
$ palmtopnm /path/to/bitmap.palm > /path/to/bitmap.ppm
$ file /path/to/bitmap.ppm
/path/to/bitmap.ppm: Netpbm image data

The exact description from file depends on the image, so treat it as a quick sanity check rather than a complete proof. A successful conversion normally produces no progress text on standard output because that stream contains the image. If you use -verbose, informational text is displayed while the image remains the command's output.

This example creates or replaces /path/to/bitmap.ppm. Before running it on a valuable output, choose a new destination or make a backup. Recovery is simple if the destination is disposable: remove the generated PPM and repeat the conversion. The Palm Bitmap source is not changed.

3. Read from standard input when a pipeline is useful

The input filename is optional. This makes it possible to pass a file through a pipeline while keeping the PPM destination explicit:

$ palmtopnm < /path/to/bitmap.palm > /path/to/bitmap.ppm
$ test -s /path/to/bitmap.ppm && printf '%s\n' 'PPM output was written'
PPM output was written

Use one input source at a time. A named file and standard input should not be treated as two images to combine. Keep the output redirection separate from diagnostic messages so that a downstream image reader receives only PPM data.

If conversion fails, rerun without overwriting the destination and capture the diagnostic stream:

$ palmtopnm /path/to/bitmap.palm > /tmp/palmtopnm-test.ppm
$ status=$?
$ printf 'palmtopnm exit status: %s\n' "$status"
palmtopnm exit status: 0

Only treat status 0 as a successful conversion. A non-zero status can leave a partial output file, so do not pass that file to another image-processing step as if it were complete. Delete the temporary file once you have inspected the error:

$ rm -f /tmp/palmtopnm-test.ppm

4. Select a different rendition

A Palm Bitmap can contain several renditions of the same image at different depths. By default, palmtopnm uses rendition number 1. If the file contains more renditions, choose one with a number from 1 through the number available:

$ palmtopnm -rendition 2 /path/to/bitmap.palm > /path/to/bitmap-rendition-2.ppm

There is no universal safe value for the number. Start with the default, then use -verbose to inspect information about the input before selecting another rendition:

$ palmtopnm -verbose /path/to/bitmap.palm > /tmp/bitmap-verbose.ppm
$ printf 'exit status: %s\n' "$?"
exit status: 0

Keep the verbose output out of the PPM file if you redirect diagnostics separately on a shell or script that needs strict stream handling. If rendition 2 is outside the file's range, the command should fail rather than silently inventing a rendition. Use the exact available range reported by the command and remove any partial output after a failed attempt.

5. Inspect transparency without generating an image

Use -transparent when you need the Palm Bitmap's transparent colour rather than a converted image:

$ palmtopnm -transparent /path/to/bitmap.palm
#RRGGBB

The value is printed as a hash followed by six hexadecimal digits, such as #00FF80. The letters and digits represent red, green and blue values from 0 through 255. If the Bitmap has no transparent colour, the command writes nothing. This mode does not generate a PPM image, so do not redirect it to a file that you expect an image viewer to open.

Capture the value only when it exists:

transparent=$(palmtopnm -transparent /path/to/bitmap.palm)
if [ -n "$transparent" ]; then
    printf 'transparent colour: %s\n' "$transparent"
else
    printf '%s\n' 'no transparent colour is set'
fi

Quote the variable when you reuse it. Do not assume that an empty result is an error: it is the documented result for a Bitmap without a transparent colour.

6. Make a transparency mask when needed

palmtopnm does not create a transparency mask itself. The Netpbm manual documents a separate pipeline using ppmcolormask, with the colour read from the same source file:

$ ppmcolormask "$(palmtopnm -transparent /path/to/bitmap.palm)" \
    < /path/to/bitmap.ppm > /path/to/bitmap-mask.pgm

Use that only when the transparent-colour query returns a value and the PPM was produced from the same Bitmap rendition. If the query is empty, stop instead of passing an empty colour argument. The pipeline writes a new mask file; it does not alter either source file. Check that ppmcolormask exists with command -v ppmcolormask before using the example.

7. Handle the usual mistakes

  • If binary data appears in the terminal, you omitted the output redirection. Press Ctrl-C if necessary, then repeat with > output.ppm.
  • If the output is empty or incomplete, inspect the exit status immediately after palmtopnm and remove the partial file before retrying.
  • If a rendition number fails, it may be outside the file's available range. Try the default and inspect -verbose output before choosing another number.
  • If -transparent prints nothing, that can mean no transparent colour is set. It does not mean that a PPM image was emitted.
  • Do not use the old -forceplain option from pre-10.23 documentation. The manual says the common -plain option made it redundant, and it is not part of this guide's command examples.

Done means

  • palmtopnm --version identified the installed Netpbm build.
  • A readable Palm Bitmap was converted to a new PPM file with exit status 0.
  • The image output was redirected away from the terminal and checked.
  • You know that rendition 1 is the default and that other values must be in range.
  • You checked transparency separately and did not mistake an empty result for image output.
  • Any temporary or partial files were removed, and the original Palm Bitmap remains unchanged.