Home / Alt manpages / pbmto10x(1)

  • pbmto10x(1)
  • User command
  • linux

Print a PBM image with pbmto10x without corrupting your shell output

You will turn a PBM bitmap into the printer-control stream used by a Gemini 10X, with the stream redirected to a file ready for the printer. You will also test the 120 by 144 high-resolution mode without sending escape sequences to your terminal. Allow about fifteen minutes, including a small conversion test. You need the netpbm package and a readable PBM file.

This guide describes the installed Netpbm package, version 2:11.05.02-1.1build1, and its pbmto10x command. The local manual page is dated 1 January 1990, so treat the observed output and option set as the behaviour to verify on the machine that will drive the printer.

1. Check the command before using it

Confirm that the executable is installed and read the synopsis:

$ command -v pbmto10x
/usr/bin/pbmto10x
$ man pbmto10x

The command accepts one optional PBM file argument. If you omit it, it reads the PBM image from standard input. In both cases it writes Gemini 10X printer graphics to standard output. The output is not a PBM file, text, or a preview image.

Checkpoint: decide where the printer stream will go before running the conversion. Do not run an unredirected conversion in a terminal. Its control bytes may alter terminal behaviour or leave unreadable characters in your scrollback.

2. Make a safe small test

Use a new temporary destination for the first run. This example creates a tiny plain PBM in /tmp; it does not change system configuration or require sudo:

$ printf 'P1\n8 4\n0 1 0 1 0 1 0 1\n1 0 1 0 1 0 1 0\n0 0 0 0 1 1 1 1\n1 1 1 1 0 0 0 0\n' > /tmp/pbmto10x-test.pbm
$ pbmto10x /tmp/pbmto10x-test.pbm > /tmp/pbmto10x-test.out
$ printf 'conversion status: %s\n' "$?"
conversion status: 0

The shell redirection writes the printer graphics to /tmp/pbmto10x-test.out. The input remains unchanged. A status of zero means the command completed its conversion; it does not prove that a physical printer is connected or that the bitmap will look as intended on paper.

Inspect the result as bytes, not as text:

$ wc -c /tmp/pbmto10x-test.out
18 /tmp/pbmto10x-test.out
$ od -An -tx1 -N 18 /tmp/pbmto10x-test.out
 1b 41 08 1b 4b 08 00 50 90 50 90 60 a0 60 a0 0a
 1b 40

The exact byte sequence depends on the PBM image and the installed implementation. The useful checks are a successful exit status and a non-empty output file. Keep the input PBM until you have tested the printer result.

3. Convert a real image at normal resolution

For a real file, replace the placeholder path and choose a new output name:

$ pbmto10x /path/to/input.pbm > /path/to/output.10x
$ test -s /path/to/output.10x && echo 'printer stream is non-empty'
printer stream is non-empty

The normal resolution is 60 dots horizontally by 72 dots vertically. The manual does not describe this as a resize operation: pbmto10x translates the PBM image into printer graphics at that resolution. If the image is intended for landscape printing, consider rotating the PBM with a separate image tool before this step. Do not assume that the printer or the converter will rotate it for you.

Keep the output extension descriptive rather than calling it .pbm. That makes it less likely that another tool will mistake printer control data for an image. Do not open the file in an editor or pass it to an image viewer expecting a bitmap.

4. Select the high-resolution mode deliberately

Add -h when you want 120 dots horizontally by 144 dots vertically:

$ pbmto10x -h /path/to/input.pbm > /path/to/output-high.10x
$ test -s /path/to/output-high.10x && echo 'high-resolution stream is non-empty'
high-resolution stream is non-empty

-h is a mode selection, not a help request. The higher resolution can produce a larger printer stream and may change the physical layout. Use it only after confirming that the target Gemini 10X and the paper setup suit the result. The command itself does not send anything to a device; redirection only creates a file.

Checkpoint: compare the two files before printing if you are unsure which mode you selected:

$ wc -c /path/to/output.10x /path/to/output-high.10x
  ... /path/to/output.10x
  ... /path/to/output-high.10x
  ... total

The byte counts are implementation and image dependent. They are a quick confirmation that you did not accidentally overwrite the normal-resolution file with the high-resolution conversion.

5. Use standard input in a pipeline

The input file is optional, so another PBM-producing command can feed pbmto10x. Keep the printer stream as the final redirected output:

$ pbm-producing-command | pbmto10x > /path/to/pipeline-output.10x
$ test -s /path/to/pipeline-output.10x && echo 'pipeline completed'
pipeline completed

pbm-producing-command is a placeholder, not a command supplied by pbmto10x. It must write a valid PBM stream to standard output. If the producer fails, do not treat a non-empty destination as proof of a valid image. In a script, enable pipeline failure reporting with the shell's normal pipeline-status facility and check the final file before sending it to a printer.

6. Avoid truncating a useful printer stream

Shell redirection with > truncates an existing destination before pbmto10x starts. When replacing a known-good stream, convert to a temporary name first, then replace it only after a successful status and a non-empty-file check:

$ pbmto10x /path/to/input.pbm > /path/to/output.10x.new
$ status=$?
$ if [ "$status" -eq 0 ] && [ -s /path/to/output.10x.new ]; then
>     mv /path/to/output.10x.new /path/to/output.10x
> else
>     printf 'conversion failed; original output was kept\n' >&2
>     rm -f /path/to/output.10x.new
>     exit "$status"
> fi

mv here replaces the old file, so use it only when that is the intended change. Recovery is simple if conversion fails: the old output remains in place, and the incomplete .new file is removed. Do not print an unverified stream to a live printer.

7. Diagnose the common failures

A missing or unreadable input produces a non-zero status and an error on standard error. Check the path without changing it:

$ ls -l /path/to/input.pbm
$ test -r /path/to/input.pbm && echo readable

An error about the PBM magic number usually means the input is empty or is not a PBM image. Check its first bytes with od, or regenerate it with a trusted PBM-producing tool. Do not rename a PNG, JPEG or printer stream to .pbm and expect the suffix to convert it.

If output is unexpectedly blank or badly arranged, verify the source PBM independently and try the normal mode before adding -h. The program has no reverse converter: there is no 10xtopbm tool in this Netpbm interface, so retain the original PBM as your recoverable source.

No example here needs elevated privileges. Use sudo only if your chosen input or destination is genuinely protected by filesystem permissions, and prefer writing a working copy in a directory you own. Sending bytes to a printer is an external, potentially irreversible action, so inspect the file and confirm the printer target before issuing any device-specific print command.

Done means

  • pbmto10x is installed and its package version is known.
  • The PBM input remains available and the conversion exits with status zero.
  • The Gemini 10X stream is redirected to a separate, non-empty file.
  • -h is used only when the 120 by 144 mode is wanted.
  • The stream has been checked as binary data before any printer receives it.
  • A failed replacement leaves the previous output intact.