Home / Alt manpages / pbmtoln03(1)

  • pbmtoln03(1)
  • User command
  • linux

Convert a PBM image into LN03+ Sixel output with pbmtoln03

By the end of this guide, you will have converted a portable bitmap (PBM) file into DEC LN03+ Sixel data and checked that the output is a non-empty file. The command writes Sixel data to standard output, so save it rather than letting a normal terminal interpret the escape sequences.

Allow about 10 minutes if you already have a PBM file. You need a shell, the Netpbm package, and an LN03+ printer or downstream tool that understands its Sixel format if you intend to use the result. No elevated privileges are needed for conversion when you can read the input and write the destination directory.

1. Check the installed command

Start by checking that the executable is available and record the version. This matters because the installed documentation describes a small, older-style interface, while distributions can package different Netpbm releases.

command -v pbmtoln03
pbmtoln03 --version

On the machine used for this guide, the command reports Netpbm 11.5.2, packaged as netpbm 2:11.05.02-1.1build1. The version query also prints build details. Do not treat those details as conversion output.

Checkpoint

command -v prints a path such as /usr/bin/pbmtoln03, and the version output identifies Netpbm.

2. Prepare or choose a PBM input

pbmtoln03 accepts one PBM filename. If you have an existing bitmap, use that path and skip the test image. For a harmless local test, create a tiny plain PBM under /tmp:

cat > /tmp/pbmtoln03-test.pbm <<'PBM'
P1
8 8
0 0 0 0 0 0 0 0
0 1 1 0 0 1 1 0
0 1 1 0 0 1 1 0
0 0 0 0 0 0 0 0
0 1 0 0 0 0 1 0
0 0 1 0 0 1 0 0
0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0
PBM
file /tmp/pbmtoln03-test.pbm

The PBM header is P1, followed by the width and height, then one text pixel value per position. In PBM, 1 is foreground and 0 is background. This file contains no printer control data; it is only a reproducible input.

Checkpoint

file should identify a Netpbm portable bitmap, or at least show that the file exists. If it does not, stop and correct the input path before converting.

3. Convert the bitmap and save the Sixel stream

Run the command with the PBM filename, redirecting standard output to a new file:

pbmtoln03 /tmp/pbmtoln03-test.pbm > /tmp/pbmtoln03-test.sixel
status=$?
printf 'exit status: %s\n' "$status"
wc -c /tmp/pbmtoln03-test.sixel

A successful run has exit status 0 and a non-zero byte count. The file is DEC LN03+ Sixel output, not a portable image that an ordinary image viewer can open. Its bytes may include escape characters, so do not print it with cat into a terminal you care about. Redirecting output also prevents a terminal emulator from attempting to render or interpret it.

For a real input, substitute its path:

pbmtoln03 /path/to/input.pbm > /path/to/output.sixel
test -s /path/to/output.sixel && printf '%s\n' 'Sixel output was written'

Checkpoint

The exit status is 0 and the output file is larger than zero bytes. A zero-byte result is not a usable conversion.

4. Set the LN03+ page margins when needed

The defaults are printer-oriented values: left margin 0, right margin 2400, top margin 0, bottom margin 3400, and form length 3400. The option takes its numeric value as a separate argument. Use the option letter followed by a number, then the PBM filename.

pbmtoln03 -l 100 -r 2300 -t 100 -b 3300 -f 3300 \
  /tmp/pbmtoln03-test.pbm > /tmp/pbmtoln03-margins.sixel
test -s /tmp/pbmtoln03-margins.sixel

Here, -l is the left margin, -r the right margin, -t the top margin, -b the bottom margin, and -f the form length. The values are device units used by the LN03+ output format, not pixels and not millimetres. Confirm the units expected by the printer or consumer before changing them.

Do not guess margins to solve a cropped or misplaced print. Change one value at a time, retain the original output, and compare the result on the target device. A bad margin can make an otherwise valid stream print outside the usable page area.

5. Diagnose the common failures

  • Missing input: check the exact path and permissions with ls -l /path/to/input.pbm. The conversion cannot read a file that is absent or inaccessible.
  • Wrong format: pbmtoln03 is for PBM, not an arbitrary PNG, JPEG or colour PPM file. Convert the source to PBM with an appropriate Netpbm tool before running this command.
  • Unexpected terminal characters: the output is a printer control stream. Redirect it to a file or pipe it to the controlled consumer; do not paste it into a shell or open it as text.
  • Margins do not behave as expected: recheck each numeric option and remember that the defaults and values are LN03+ device units.

The documented common option -quiet is available through libnetpbm if you need to suppress routine messages. Keep diagnostics visible while testing so that a failed conversion is not mistaken for an empty or valid result.

Done means

  • The installed Netpbm version is recorded.
  • A valid PBM input was supplied as the single positional argument.
  • Standard output was redirected to a Sixel file.
  • The command returned 0 and test -s or wc -c confirmed output.
  • Any margin changes used verified LN03+ device units and did not overwrite the original output.