Home / Alt manpages / cmuwmtopbm(1)

  • cmuwmtopbm(1)
  • User command
  • linux

Convert CMU Window Manager Bitmaps to PBM with cmuwmtopbm

Old CMU window manager bitmaps show up in archives that no modern tool wants to open, but cmuwmtopbm still converts them into a usable PBM image. It reads the bitmap, writes PBM to standard output, and gets out of the way. The installed version is Netpbm 11.5.2.

Allow about ten minutes if the source bitmap is already sitting on disk. You need the netpbm package and a readable .cmuwm file; nothing here needs elevated privileges.

1. Check the installed command

cmuwmtopbm has one positional input argument and no command-specific switches of its own.

$ command -v cmuwmtopbm
/usr/bin/cmuwmtopbm
$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1
$ cmuwmtopbm --version
cmuwmtopbm: Using libnetpbm from Netpbm Version: Netpbm 11.5.2

Version output includes build details after the Netpbm version, and exact packaging text will differ on another distribution. Keep the package and library version handy when comparing results with someone else's.

2. Convert a bitmap to PBM

Give the input as the optional cmuwmfile argument and redirect standard output to a new file:

$ cmuwmtopbm /path/to/window-manager-bitmap.cmuwm > /path/to/window-manager-bitmap.pbm

This is an ordinary, unprivileged conversion: do not reach for sudo just because the format is unfamiliar. You only need read access to the input and write access to the destination directory.

Checkpoint

Inspect the result without opening binary pixel data in a text editor.

$ file /path/to/window-manager-bitmap.pbm
/path/to/window-manager-bitmap.pbm: Netpbm image data, size = WIDTH x HEIGHT, rawbits, bitmap
$ head -c 2 /path/to/window-manager-bitmap.pbm
P4

A raw PBM file starts with the magic number P4. The dimensions in the file output should match the bitmap you meant to convert; everything after the header is binary image data, so it will look like noise on a terminal.

3. Use standard input when that fits the workflow

The filename argument is optional. With none given, cmuwmtopbm reads the CMU bitmap from standard input and still writes PBM to standard output:

$ cmuwmtopbm < /path/to/window-manager-bitmap.cmuwm > /path/to/window-manager-bitmap.pbm
$ test -s /path/to/window-manager-bitmap.pbm && echo 'PBM output is non-empty'
PBM output is non-empty

Handy in a pipeline, but it hides the input source from anyone reading the script later. Use the named argument for a short-lived command, and standard input when another tool is already producing the bitmap.

4. Protect an existing output file

Warning

Shell redirection with > truncates the destination before cmuwmtopbm even starts, which is a destructive overwrite if that file already held a good PBM.

  • Convert to a temporary name first. Write beside the real destination, not over it.
  • Check it. Confirm the file is non-empty and looks like the expected image before you touch the original.
  • Only then replace it. A rename is quick to undo if you kept the old file; a truncated overwrite is not.
$ cmuwmtopbm /path/to/window-manager-bitmap.cmuwm > /path/to/window-manager-bitmap.pbm.new
$ test -s /path/to/window-manager-bitmap.pbm.new
$ file /path/to/window-manager-bitmap.pbm.new
/path/to/window-manager-bitmap.pbm.new: Netpbm image data, size = WIDTH x HEIGHT, rawbits, bitmap
$ mv /path/to/window-manager-bitmap.pbm.new /path/to/window-manager-bitmap.pbm

Run that final mv only once you have confirmed the temporary file is the image you expected. If conversion fails, the original destination is untouched; remove the incomplete temporary with rm -- /path/to/window-manager-bitmap.pbm.new after checking it, and do not fold that into an automatic recovery script unless you have named the exact file.

5. Diagnose the common failures

A wrong or unreadable input path makes the command exit non-zero with the operating system's own error, so check first without changing anything:

$ ls -l -- /path/to/window-manager-bitmap.cmuwm
$ test -r /path/to/window-manager-bitmap.cmuwm && echo readable
readable

A missing file produces something like Unable to open file ... for reading. Fix the path or permissions and rerun; do not mistake a created-but-empty output for success, since redirection can create that file before the converter ever reports the error.

If the PBM dimensions look wrong, check first that the input really is a CMU window manager bitmap and was not truncated in an earlier transfer. cmuwmtopbm has no option to resize or repair anything: a clean exit only means the parser finished, not that the source was the file you intended. Keep the original until the PBM opens correctly in a viewer or converts cleanly with another Netpbm tool.

Common traps

  • Treating a zero-byte file as fine. Redirection creates the destination before the program can fail; always check size, not just existence.
  • Skipping the format check. A successful conversion of the wrong input format is still the wrong output.
  • Reaching for sudo. This tool never needs it for files in your own working directory; if the source is protected, copy it to a working directory through your normal access process first.

Done means

  • Command checked. The installed cmuwmtopbm and Netpbm version match what you expect.
  • Conversion produced output. The CMU bitmap became a non-empty PBM file.
  • Format verified. The output starts with the P4 magic number and has sensible dimensions.
  • Existing files protected. No PBM was lost to a failed direct overwrite.
  • Original kept. The source bitmap is still available for a second attempt.