Home / Alt manpages / rlatopam(1)

  • rlatopam(1)
  • User command
  • linux

Convert RLA and RPF Images to PAM with rlatopam

You will convert an Alias/Wavefront RLA or RPF image into a PAM image file, while keeping the original untouched and checking the result with Netpbm tools. Allow about ten minutes if the input path is known. You need the netpbm package and a readable image file.

This guide describes Netpbm 11.5.2, the version installed on this machine. The local manual page is older than the installed package, so the package version and the command probes below are the practical reference here. The converter has no RLA or RPF output mode in Netpbm: it only converts in this direction.

1. Check the installed converter

Confirm the command and library version before building it into a script. These are ordinary read-only commands and do not need sudo:

$ command -v rlatopam
/usr/bin/rlatopam
$ rlatopam -version
rlatopam: Using libnetpbm from Netpbm Version: Netpbm 11.5.2
rlatopam: Built from source dated 2024-03-31 09:09:47
rlatopam: Built by Debian
rlatopam: BSD defined
rlatopam: RGB_ENV='RGBDEF'
rlatopam: RGBENV= 'RGBDEF' (env vbl is unset)

The -version option reports the linked Netpbm library and then exits. It does not convert an image. The shared Netpbm options also include -quiet for informational messages and -plain, but plain output does not change PAM because PAM has no plain and raw variants.

2. Check the input without changing it

Use a real path in place of /path/to/input.rla. The file can have an RLA or RPF image format; the filename suffix is not the conversion setting. Check that the path is readable:

$ ls -l /path/to/input.rla
$ test -r /path/to/input.rla && echo 'input is readable'
input is readable

If the first command cannot find the file, correct the path rather than adding elevated privileges. If the file belongs to another user or directory access is restricted, resolve that access through your normal system administration process. Do not make a copy with changed permissions unless you understand the data's sensitivity.

3. Convert to a new PAM file

rlatopam writes its PAM image to standard output. Redirect that stream to a new destination:

$ rlatopam /path/to/input.rla > converted.pam
$ printf 'rlatopam exit status: %s\n' "$?"
rlatopam exit status: 0

A successful status means the command completed. It does not by itself prove that the image has the dimensions or channels you expected. The output may be grayscale or RGB, with or without transparency, because those are formats rlatopam can represent in PAM.

Checkpoint: the input file should still have its original timestamp and size. The destination is a separate file:

$ file /path/to/input.rla converted.pam
/path/to/input.rla: [description depends on the source]
converted.pam: Netpbm PAM image file
$ pamfile converted.pam
converted.pam:	PAM, [width] by [height] pixels, [tuple type] format

The exact file and pamfile descriptions depend on the image and installed utility versions. The bracketed values above are placeholders for the output you will see, not text to type. Check that the destination is recognised as PAM and that its dimensions and tuple type are plausible for the source. Keep the source until this check and a visual inspection have succeeded.

4. Use standard input in a pipeline

The filename argument is optional. When it is omitted, rlatopam reads the RLA or RPF image from standard input. That makes it suitable for a pipeline where another program supplies the bytes:

$ cat /path/to/input.rpf | rlatopam > converted-from-rpf.pam
$ pamfile converted-from-rpf.pam
converted-from-rpf.pam:	PAM, [width] by [height] pixels, [tuple type] format

For a single local file, naming the input directly is easier to audit. The pipeline form is useful when the producer already writes to standard output. Do not use a text filter between the producer and rlatopam: RLA and RPF are binary image formats.

5. Protect an existing output

Shell redirection with > truncates an existing destination before rlatopam starts. That is destructive if converted.pam is valuable. Write to a temporary name in the same directory and replace the old file only after validation:

$ rlatopam /path/to/input.rla > converted.pam.new
$ pamfile converted.pam.new
converted.pam.new:	PAM, [width] by [height] pixels, [tuple type] format
$ mv converted.pam.new converted.pam

The mv command changes the destination name and can replace an existing file. Treat that as the point of no return for the old output. If conversion or validation fails, leave the old file alone and remove the incomplete converted.pam.new only after checking its path:

$ rm converted.pam.new

That removal is irreversible. The conversion itself does not alter the input image, so there is no source-file undo step.

6. Diagnose a failed conversion

A missing input produces a non-zero status and an error on standard error. For example, this is a safe diagnostic because the path does not identify a real source:

$ rlatopam /tmp/does-not-exist.rla > failed.pam
rlatopam: Unable to open file '/tmp/does-not-exist.rla' for reading. fopen() returns errno 2 (No such file or directory)
$ printf 'status: %s\n' "$?"
status: 1

Because the shell creates the redirection target before starting the command, a failed run can leave an empty or partial output. Use the temporary-name workflow when this matters. If you piped the input, test the producer separately and remember that a pipeline's final status is normally rlatopam's status unless you enable your shell's pipeline failure handling.

Empty or malformed input is also rejected. The installed command reports an unexpected end of input and returns non-zero. Do not treat a file that merely has an .rla or .rpf suffix as valid. Recheck the producer, permissions and file transfer, then rerun into a new temporary destination.

Done means

  • The installed command and Netpbm version were checked.
  • The RLA or RPF source remained unchanged.
  • rlatopam completed with status 0 and produced a PAM file.
  • pamfile confirmed the output dimensions and tuple type.
  • An existing output was protected by converting to a new name first.
  • No elevated privileges or persistent system changes were needed.