Home / Alt manpages / pbmtodjvurle(1)

  • pbmtodjvurle(1)
  • User command
  • linux

Convert a PBM Image to DjVu Bitonal RLE with pbmtodjvurle

pbmtodjvurle turns a Portable Bitmap into DjVu Bitonal Run-Length Encoding, leaving the original image untouched. Because the command writes its result to standard output, the normal workflow is a pipeline or a shell redirect. Allow about ten minutes if the PBM is ready.

You need a Linux shell, the netpbm package, and a readable PBM file. These examples use Netpbm 11.5.2 from Debian package netpbm 2:11.05.02-1.1build1. The installed manual describes pbmtodjvurle as a PBM-to-DjVu Bitonal RLE converter with no command-specific options.

1. Check the installed command

Confirm which executable will run and ask it for help. Both are ordinary, read-only checks that need no elevated privileges:

$ command -v pbmtodjvurle
/usr/bin/pbmtodjvurle
$ pbmtodjvurle --help
pbmtodjvurle: Use 'man pbmtodjvurle' for help.

That brief help message is normal for this Netpbm tool. The manual page is the real reference: the program accepts a PBM input file, or reads standard input when none is supplied, and writes DjVu Bitonal RLE to standard output.

Checkpoint

Verify the package version if you're documenting a script or chasing a difference between machines:

$ dpkg-query -W -f='${Package} ${Version}\n' netpbm
netpbm 2:11.05.02-1.1build1

2. Convert a PBM file to a new RLE file

Redirect standard output to a destination that doesn't already contain something valuable:

$ pbmtodjvurle /path/to/input.pbm > /path/to/output.rle

A successful run prints no progress message. Check the exit status immediately, then confirm the destination is non-empty:

$ printf 'conversion status: %s\n' "$?"
conversion status: 0
$ test -s /path/to/output.rle && printf '%s\n' 'RLE output is non-empty'
RLE output is non-empty

The output is binary, so don't inspect it in a text editor or expect file to name it with a friendly image description. A small valid result begins with an RLE header, but the safest first checks are exit status and file size. Keep the PBM input until a later DjVu reader has accepted the result.

3. Use standard input and output in a pipeline

With no input filename, pbmtodjvurle reads standard input, which lets another Netpbm program feed it directly, or lets you make the source explicit with a redirect:

$ pbmtodjvurle < /path/to/input.pbm > /path/to/output.rle
$ printf 'pipeline status: %s\n' "$?"
pipeline status: 0

A single hyphen also works as the input filename on the installed command:

$ pbmtodjvurle - < /path/to/input.pbm > /path/to/output.rle

Don't mix up the two ends of the command. Input comes from the optional argument or standard input; the result goes to standard output, which the shell redirect saves. There's no output filename argument in this build.

4. Avoid overwriting an existing result

Shell redirection with > truncates the destination before the converter starts. If the output name already matters, write a temporary result and move it into place only after conversion succeeds:

$ pbmtodjvurle /path/to/input.pbm > /path/to/output.rle.new
$ status=$?
$ if [ "$status" -eq 0 ] && [ -s /path/to/output.rle.new ]; then
>     mv -- /path/to/output.rle.new /path/to/output.rle
> else
>     printf 'conversion failed with status %s\n' "$status" >&2
>     rm -- /path/to/output.rle.new
>     exit "$status"
> fi

The mv replaces the old output only after a successful, non-empty conversion. The final rm is destructive only to that freshly created temporary file. Check the paths carefully before adapting this pattern. No command in the normal conversion needs sudo; use elevated privileges only when the input directory or destination is genuinely protected, and fix ownership or permissions instead where you can.

5. Diagnose the common argument mistake

The installed binary accepts at most one command-line argument, the input filename. Pass an output filename as a second argument and it fails before conversion even starts:

$ pbmtodjvurle /path/to/input.pbm /path/to/output.rle
pbmtodjvurle: Program takes at most 1 argument -- the input file name. You specified 2

Worth flagging: the installed manual's synopsis shows an optional rlefile position, but the Netpbm binary on this machine rejects two arguments outright. Trust the behaviour of the installed executable over the synopsis: redirect standard output instead of supplying a second filename. If another host behaves differently, record its Netpbm version and rerun the help and conversion checks before changing a script.

If the command reports an input error, check the path and readability first, without changing anything:

$ ls -l /path/to/input.pbm
$ test -r /path/to/input.pbm && printf '%s\n' 'input is readable'
$ pbmtodjvurle /path/to/input.pbm > /tmp/pbmtodjvurle-check.rle
$ printf 'status: %s\n' "$?"
status: 0

Swap in a location you control for that temporary path. If the status is non-zero, don't treat a partially written file as a valid conversion: remove or quarantine it after checking the status, then correct the input format or path. A PBM file has to be a genuine Netpbm bitmap, not a similarly named colour image.

Done means

  • Version known. The installed pbmtodjvurle and Netpbm version are confirmed.
  • Conversion clean. A readable PBM input produced a non-empty DjVu Bitonal RLE output with status 0.
  • Output captured properly. Standard-output redirection or a pipeline, not a bare terminal dump.
  • Existing result protected. Nothing got truncated prematurely.
  • No stray arguments or sudo. A second filename was never passed to the installed binary, and sudo was never needed.