Home / Alt manpages / sirtopnm(1)

  • sirtopnm(1)
  • User command
  • linux

Convert Solitaire Image Recorder Files to PNM with sirtopnm

You will finish with a PGM or PPM image converted from a Solitaire Image Recorder file, plus a quick check that the output format and dimensions are sensible. The examples use sirtopnm from Netpbm 11.05.02-1.1build1, installed here on Linux.

Allow about ten minutes. You need a readable Solitaire file, a shell, and enough free space for the output. This is an ordinary user-level conversion: it should not need sudo. Keep the original file until you have checked the converted image.

1. Check the installed command

Confirm which executable will run and record the package version. These are read-only checks:

$ command -v sirtopnm
/usr/bin/sirtopnm
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 11.05.02-1.1build1

The installed manual describes sirtopnm as a converter for Solitaire Image Recorder files. It has no command-line options specific to this program. It accepts one optional input filename, so the basic interface is deliberately small.

Checkpoint: if command -v prints nothing, stop and install Netpbm through your normal package-management process. Do not copy a binary from an unknown source merely to process an old image.

2. Inspect the input before converting it

Use a path to the file you actually intend to read. Check that it exists and is readable without changing it:

$ INPUT='/path/to/image.sir'
$ ls -l -- "$INPUT"
$ test -r "$INPUT" && echo 'input is readable'
input is readable

Replace the placeholder with your real path. Quoting the variable protects spaces and most shell metacharacters in the filename. If ls reports that the file does not exist, fix the path first. A permission problem is not solved by changing the file or running the converter as root.

SIR files may be identified by their contents rather than their filename suffix. If the file command is installed, it can provide a useful non-destructive hint:

$ file -- "$INPUT"
/path/to/image.sir: Solitaire Image Recorder format MGI Type 17

The exact description varies with the file and the installed file database. An MGI Type 17 file is the grayscale form; an MGI Type 11 file is the 24-bit colour form.

3. Convert to a new output file

sirtopnm writes the converted PNM image to standard output. Redirect it to a new filename so a failed conversion cannot truncate an existing image:

$ OUTPUT='/path/to/image.pnm'
$ sirtopnm -- "$INPUT" > "$OUTPUT"
sirtopnm: Writing a PGM file

The diagnostic tells you the output family. For MGI Type 17, the command writes PGM. For MGI Type 11, it writes PPM. The diagnostic is written to standard error, while the image bytes go to the redirected standard output. Do not redirect standard error into the image file.

The -- marker makes the boundary between the command and the input path explicit. The installed program accepts it in this position. If your filename begins with a hyphen, this also avoids treating it as an option. A safer naming convention is still to store image files with ordinary names.

There is no overwrite protection in shell redirection. The > operator truncates an existing destination before sirtopnm starts. Before using an important output name, choose a new path or make a copy:

$ OUTPUT='/path/to/image.pnm.new'
$ sirtopnm -- "$INPUT" > "$OUTPUT"
$ test -s "$OUTPUT" && echo 'conversion produced a non-empty file'
conversion produced a non-empty file

Only after checking the new file should you replace an older result. If the conversion fails, remove the incomplete .new file with the exact path you selected. That deletion is irreversible, so do not include it in an unattended batch until the workflow is proven.

4. Convert from standard input when needed

With no filename argument, sirtopnm reads the SIR data from standard input. This is useful in a pipeline or when another program supplies the bytes:

$ sirtopnm < '/path/to/image.sir' > '/path/to/image.pnm'
sirtopnm: Writing a PGM file

The two redirects have different jobs: the left one supplies the input stream and the right one captures the PNM output. Keep the diagnostic visible so you can tell whether the result is PGM or PPM. Avoid pipelines that hide a failed producer unless you also check the pipeline's status in your shell.

5. Verify the output before using it

First check that the destination is non-empty and that its image type is what sirtopnm reported:

$ file -- "$OUTPUT"
/path/to/image.pnm: Netpbm image data, size = 640 x 480, rawbits, greymap
$ head -c 2 -- "$OUTPUT"
P5

For a colour result, file normally reports a pixmap and the PNM magic number is P6. A grayscale result normally reports a greymap and starts with P5. The dimensions depend on the source, so do not treat the sample size as a default.

Do not inspect a binary PGM or PPM in a text editor. Its header is text, but the pixel data is binary. Open it with an image viewer or pass it to a separate Netpbm converter if you need a more convenient format. That later conversion is not part of sirtopnm and should be checked separately.

6. Diagnose a failed conversion

A missing or unreadable input usually points to the path or permissions. Re-run the read-only checks:

$ ls -l -- "$INPUT"
$ test -r "$INPUT" && echo readable || echo 'not readable'
not readable

If the input is readable but sirtopnm rejects it, preserve the original and capture the diagnostic in a separate text file while testing a fresh destination:

$ sirtopnm -- "$INPUT" > '/tmp/sirtopnm-test.pnm' 2> '/tmp/sirtopnm-test.err'
$ cat '/tmp/sirtopnm-test.err'
$ test -s '/tmp/sirtopnm-test.pnm' && echo 'output exists'
output exists

An output file existing does not prove that the conversion is usable, so still run file and inspect the image. If the source is corrupt or is not a supported SIR file, keep it unchanged and recover another copy from the original archive. Do not 'repair' the source by editing binary bytes.

Done means

  • The installed Netpbm version and sirtopnm executable were checked.
  • The input file was confirmed readable without modifying it.
  • A new output file was created with standard output redirection.
  • The diagnostic identified PGM or PPM, and file confirmed the result.
  • The output magic number was checked as P5 for grayscale or P6 for colour.
  • The original SIR file remains available for recovery.