Home / Alt manpages / pjtoppm(1)

  • pjtoppm(1)
  • User command
  • linux

Convert an HP PaintJet File to PPM with pjtoppm

You will finish with a PPM image made from an HP PaintJet file, plus a quick check that the output is really a usable PPM image. The examples use pjtoppm from Netpbm package version 2:11.05.02-1.1build1, installed as /usr/bin/pjtoppm.

Allow about ten minutes if you already have the source file. You need a shell, a PaintJet raster file, enough free space for the output, and a Netpbm installation containing pjtoppm. This converter has no converter-specific switches and only implements a small subset of PaintJet commands, so unusual printer-control files may fail or produce incomplete images.

1. Check the installed converter

Confirm the executable and read its short help response. This is an ordinary read-only check and does not need elevated privileges:

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

The non-zero help status is not a conversion failure. This old Netpbm program directs help requests to its manual page. Read the local contract with:

$ man pjtoppm

Checkpoint: the synopsis is pjtoppm [paintjet]. There is no output filename option and no named option specific to this program. The optional argument is the input file; when it is omitted, the command reads standard input.

2. Preserve the original file

Conversion should not alter the PaintJet source, but keep the original until the PPM has passed your checks. Work in a new directory if the file came from removable media or an old archive:

$ mkdir -p "$HOME/paintjet-conversion"
$ cp -- '/path/to/input.pj' "$HOME/paintjet-conversion/input.pj"
$ cd "$HOME/paintjet-conversion"
$ ls -lh -- input.pj

Replace /path/to/input.pj with the real path. Quote paths that contain spaces. The mkdir and cp commands create or copy files in your home directory, so check the destination before running them. No sudo is required. If you copied the wrong file, remove only that new copy with rm -- input.pj; do not use a wildcard in a directory containing anything else.

3. Convert the file to PPM

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

$ pjtoppm input.pj > output.ppm
$ printf 'converter status: %s\n' "$?"
converter status: 0

A zero status means the command completed according to its own checks. The PPM image is in output.ppm; diagnostics, if any, are written separately by the command. Because this old interface has no documented end-of-options marker, use a normal filename rather than one beginning with a dash. Rename such a file first if needed.

This step can overwrite an existing output.ppm because the shell opens the redirection target before starting the converter. If that file matters, stop and choose a new name. If a failed conversion leaves a partial output, delete only that output and retry after checking the source:

$ rm -- output.ppm
$ file -- input.pj

That removal is irreversible unless you have a backup. It does not touch input.pj.

4. Verify the PPM header and dimensions

Use Netpbm's pamfile to inspect the result without opening a graphical viewer:

$ pamfile output.ppm
output.ppm: PPM raw, 640 by 480 pixels, maxval 255

The dimensions and wording will vary with the source. A successful check should identify a PPM image and report plausible dimensions. If pamfile is unavailable, inspect the first bytes without modifying the file:

$ od -An -c -N 32 output.ppm
   P   6  \n   6   4   0       4   8   0  \n

PPM files use a text header beginning with P3 or P6. Netpbm commonly writes raw PPM, whose magic number is P6. Do not treat a particular width, height or byte count as universal: those values come from the PaintJet data.

Checkpoint: compare the output size with the image dimensions, then open or pass output.ppm to the next tool in your workflow. For example, an image viewer may render it directly, while another Netpbm command can convert it to PNG.

5. Use standard input for a pipeline

The input filename is optional, so a file can be supplied through standard input. This is useful when another command has already selected or unpacked the source:

$ cat -- input.pj | pjtoppm > output-from-stdin.ppm
$ pamfile output-from-stdin.ppm

For a single ordinary file, naming the file directly is easier to audit because the input is visible in the command. In a pipeline, make sure the upstream command really emits the PaintJet file bytes. A text-mode transfer, decompression error or empty stream can make pjtoppm report a format error.

6. Diagnose unsupported or damaged input

The manpage says that pjtoppm handles only enough PaintJet commands for most raster image files. It is not a general printer-language interpreter. A non-zero status or a message about the transmission mode usually means the input is not the expected PaintJet raster stream, is incomplete, or uses commands outside the converter's supported subset.

Keep the diagnostic and status together when testing:

$ pjtoppm input.pj > retry.ppm
$ status=$?
$ printf 'converter status: %s\n' "$status"
$ if [ "$status" -ne 0 ]; then
    rm -f -- retry.ppm
    printf '%s\n' 'No usable image was retained.' >&2
    exit "$status"
  fi

Do not add guessed switches to compensate. There are no pjtoppm-specific options documented by the installed manual. Check the source file's provenance, obtain a complete transfer, or try a converter designed for the actual format. The related ppmtopj command goes in the opposite direction, from PPM to PaintJet, and does not repair an invalid input.

Done means

  • pjtoppm is the installed Netpbm 11.05.02 command you intended to run.
  • The original PaintJet file remains available and was not overwritten.
  • The conversion returned status 0 and wrote a new PPM file.
  • pamfile, or a header inspection, identifies the output as PPM.
  • You treated unsupported PaintJet commands and partial input as conversion failures, not as reasons to guess options.