Home / Alt manpages / rletopnm(1)

  • rletopnm(1)
  • User command
  • linux

Convert Utah RLE Images to PNM with rletopnm

rletopnm turns a Utah Raster Toolkit RLE file into a Netpbm PGM or PPM image, transparency channel and all. This matches Netpbm 11.5.2, packaged here as netpbm version 2:11.05.02-1.1build1, and takes about ten minutes.

You need a shell, a readable RLE file and the Netpbm utilities. Nothing here needs sudo. The work is read-only except for the output files you deliberately create with shell redirection, so do not point a destination name at an original image unless overwriting it is exactly what you want.

1. Confirm the installed command

Check which executable your shell will actually run and what version it reports:

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

The real output includes a build date and platform too; wording varies, but it should identify the tool you are about to run. If command -v comes back empty, install the Netpbm package through your normal process rather than grabbing an unverified download.

Checkpoint

You have a readable RLE path, and rletopnm has confirmed itself as the Netpbm command rather than some similarly named script.

2. Peek at the header without converting anything

Use --headerdump to identify the image type or check metadata before you even pick an output name:

$ rletopnm --headerdump /path/to/input.rle
# header details are written to standard error

This writes the RLE header to standard error and produces no PGM or PPM output at all. Add --verbose if you also want the normal conversion run to narrate what it is doing while it writes the image. Short forms -h and -v work on this install, but the long forms read better in a command someone else will copy later.

$ rletopnm --headerdump --verbose "/path/to/source images/input.rle"
# inspect the diagnostic text before creating an output file
  • Quote paths with spaces. The example above shows why: an unquoted path with a space in it splits into two arguments.
  • A failure here is useful, not annoying. Check the path and read permission first; do not add elevated privileges just because of a typo.
  • Untrusted source? Keep it in a disposable working directory and do not open the converted image in anything until it has passed your usual file-safety checks.

3. Convert to the right PNM family

Redirect standard output to a new destination:

$ rletopnm --verbose /path/to/input.rle > /path/to/output.ppm

rletopnm writes PPM for pseudocolour, truecolour and directcolour RLE data, and PGM for 8-bit grayscale. The filename suffix does not decide this for you: use .pgm when you already know the source is grayscale, and .ppm otherwise. If the header from step 2 showed a different kind of image than you expected, stop and pick the destination name again before running anything.

The redirection itself is your shell's job, not rletopnm's, and it creates or truncates the destination the moment the command starts. Pick a fresh name like output-checked.ppm, or turn on your shell's no-clobber option, so you cannot silently overwrite something useful. If conversion fails after truncating a file you own, check the path carefully before removing or renaming it, then rerun into a clean destination.

Checkpoint

A successful run normally prints nothing to your terminal, because the image bytes went straight to the redirected file. Verify the result instead of trusting the silence:

$ pamfile /path/to/output.ppm
/path/to/output.ppm: Netpbm image data, size ...

Exact dimensions and wording depend on the source, but the file should come back recognised as a Netpbm image. Run the same check against the PGM output for a grayscale source and expect a graymap result.

4. Read from a pipeline

Drop the filename, or pass -, to read RLE data from standard input:

$ cat /path/to/input.rle | rletopnm - > /path/to/output.ppm

The explicit filename in this example just shows where the pipeline ends; it is equivalent to:

$ rletopnm < /path/to/input.rle > /path/to/output.ppm

Warning

Keep input and output separate. Something like rletopnm input.rle > input.rle truncates the source before the command has read a single byte of it, destroying your only copy. If you genuinely need to replace a file, write a new one first, verify it, then use your normal backup and rename procedure as a deliberate extra step.

5. Keep the transparency channel

By default rletopnm throws transparency data away. If the RLE has a transparency channel and you want it, add --alphaout to write it to a separate PGM file while the image itself still goes to standard output:

$ rletopnm --alphaout=/path/to/input-alpha.pgm /path/to/input.rle > /path/to/input.ppm
$ pamfile /path/to/input.ppm /path/to/input-alpha.pgm
/path/to/input.ppm: Netpbm image data, size ...
/path/to/input-alpha.pgm: Netpbm image data, size ...

The alpha output is a PGM of transparency values. The manual notes that a source with no transparency channel still produces an alpha file, just filled with zeroes, so having the file at all does not prove the source actually had meaningful transparency. Check the header from step 2 and your own workflow before you trust the mask.

Do not combine --alphaout=- with a normal image conversion in the same command: that sends the transparency PGM to standard output instead and drops the image entirely. It is only useful when the mask itself is what you are after.

Common traps

  • Command seems to hang. A missing filename argument makes rletopnm wait on standard input. Press Ctrl-D only if you mean to finish that input; otherwise Ctrl-C and rerun with an explicit path or pipeline.
  • Output is not recognised as PGM or PPM. Re-check the header and confirm the input really is a Utah RLE file. rletopnm only understands four families: grayscale, pseudocolour, truecolour and directcolour. A similarly named raster file will not just work.
  • Script mixes up status and binary data. Keep diagnostics on standard error and image bytes on standard output, and always check the exit status rather than assuming success from silence.

Done means

  • Confirmed the installed Netpbm version and your source path.
  • Inspected the header whenever the image type or metadata was in doubt.
  • Converted to a fresh PGM or PPM destination, never overwriting the source.
  • Verified the result with pamfile rather than trusting a quiet exit.
  • Pulled out transparency with --alphaout only when you actually needed the mask.
  • Kept input, output and diagnostics on separate streams throughout.