Home / Alt manpages / pbmtoibm23xx(1)

  • pbmtoibm23xx(1)
  • User command
  • linux

Convert PBM Images into an IBM 23XX Printer Stream

You will finish with a binary IBM 23XX printer stream generated from one or more PBM images, saved to a file ready for the printer workflow used on your host. Allow about fifteen minutes. You need Netpbm's pbmtoibm23xx, a PBM input, and somewhere safe to write the generated stream.

The examples were checked with Netpbm 11.5.2, package version 2:11.05.02-1.1build1. This is a converter, not a printer queue manager: it writes commands to standard output and does not select a printer or send data over a device by itself.

1. Check the installed command

Confirm that the executable and package are the ones you expect. This is an ordinary read-only check and does not need elevated privileges:

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

The installed binary reports the underlying Netpbm library and build details if you pass --version. Do not confuse that diagnostic output with printer data; the converted stream is written to standard output, so always redirect it to a file or a deliberately chosen transport.

Checkpoint

If command -v finds nothing, install Netpbm through your normal distribution process before continuing. Do not substitute a similarly named converter without checking its option syntax.

2. Prepare a small PBM test image

Use the plain-text PBM format for a harmless smoke test. The first line identifies format P1, the next line gives width and height, and the remaining values are black and white pixels:

$ cat > /tmp/ibm23xx-test.pbm <<'EOF'
P1
2 2
0 1
1 0
EOF

This changes only a temporary file under /tmp. Replace it with a real PBM file when you are ready, but check the input path carefully. A PBM image is not the same as a PNG, JPEG or colour PPM image; convert those formats to PBM first with a suitable Netpbm tool.

Inspect the header before converting:

$ sed -n '1,4p' /tmp/ibm23xx-test.pbm
P1
2 2
0 1
1 0

3. Choose both printer resolutions

Supply -xres for horizontal resolution and -yres for vertical resolution. Both options are mandatory. Each value must be exactly 60, 120 or 240 dots per inch:

$ pbmtoibm23xx -xres=120 -yres=120 /tmp/ibm23xx-test.pbm > /tmp/ibm23xx-stream.bin
$ printf 'converter status: %s, bytes: ' "$?"
converter status: 0, bytes: 25

The byte count is host- and image-dependent, so the number above is only the result for this 2 by 2 test image. A successful exit status means the converter completed; it does not prove that a connected printer accepts the stream.

The option forms -xres 120 and --xres=120 are also accepted. Minimum unique option abbreviations are accepted too, but spelling the complete option makes scripts easier to audit and protects them from future option additions.

Checkpoint

Confirm that the output file exists and is not empty before handing it to another program:

$ test -s /tmp/ibm23xx-stream.bin
$ printf 'stream is ready: %s bytes\n' "$(wc -c < /tmp/ibm23xx-stream.bin)"
stream is ready: 25 bytes

4. Convert several PBM files as one stream

Pass multiple PBM paths after the options. The converter reads each file and writes commands for all of their images to the same standard-output stream:

$ pbmtoibm23xx -xres=60 -yres=60 \
    /path/to/first.pbm /path/to/second.pbm \
    > /tmp/ibm23xx-batch.bin
$ printf 'converter status: %s\n' "$?"
converter status: 0

Keep the redirection outside the command. The output is printer data, not text, so sending it directly to your terminal can produce control characters or disturb the terminal session. If you need to inspect it, use a byte-oriented tool such as od, not a text editor:

$ od -An -tx1 -N 16 /tmp/ibm23xx-batch.bin
 1b 5b 40 00 00 00 00 00 00 00 00 00 00 00 00 00

The exact bytes depend on the selected resolution and input. Treat them as a diagnostic sample, not a portable format contract.

5. Read from standard input when a pipeline is useful

With no input file names, pbmtoibm23xx reads PBM data from standard input. This lets another program produce PBM without creating an intermediate image file:

$ cat /tmp/ibm23xx-test.pbm \
    | pbmtoibm23xx -xres=240 -yres=240 \
    > /tmp/ibm23xx-pipeline.bin
$ printf 'pipeline status: %s\n' "$?"
pipeline status: 0

In a longer pipeline, check the status of each stage according to your shell's rules. A successful final converter status cannot tell you whether an earlier producer emitted the PBM you intended unless that producer also reported success.

6. Use slow mode only for 120 dpi output

The -slow option selects the slower mode where two modes with the same resolution are available. The installed manual says it affects horizontal resolution 120 modes. It usually improves print quality, but increases printing time:

$ pbmtoibm23xx -xres=120 -yres=120 -slow \
    /tmp/ibm23xx-test.pbm > /tmp/ibm23xx-slow.bin
$ printf 'slow-mode status: %s\n' "$?"
slow-mode status: 0

Do not add -slow as a general quality switch for every job. Its documented effect is tied to 120 dpi horizontal output, and future versions may extend that behaviour. Compare a test print on the actual printer before changing a production workflow.

7. Diagnose rejected input without touching the printer

An unsupported resolution is rejected before useful output is produced. For example:

$ pbmtoibm23xx -xres=100 -yres=60 /tmp/ibm23xx-test.pbm > /tmp/rejected.bin
pbmtoibm23xx: Please specify 60, 120, or 240 for -xres
$ printf 'exit status: %s\n' "$?"
exit status: 1

Keep the diagnostic on standard error, as shown. If the status is non-zero, do not send the output file to a printer. Re-run with one of the three supported values and check that the output is non-empty.

For a missing or unreadable input file, fix the path or permissions rather than adding sudo automatically. Elevated privileges do not repair a wrong file name. If your final transport writes to a protected device or spool location, handle that separate permission step only after the stream has been generated and verified in a safe location.

Done means

  • You confirmed the installed Netpbm version and executable.
  • Your input is PBM, and both resolutions are 60, 120 or 240 dpi.
  • The command's binary output was redirected away from the terminal.
  • The exit status was zero and the resulting stream was non-empty.
  • You used -slow only after deciding that the 120 dpi quality and time trade-off suits the job.
  • No printer device, queue or service was changed while testing.