Home / Alt manpages / ppmtopjxl(1)

  • ppmtopjxl(1)
  • User command
  • linux

Convert PPM Images to PaintJet XL PCL with ppmtopjxl

The HP PaintJet XL speaks its own PCL dialect, and ppmtopjxl is the Netpbm tool that gets a PPM image there. This guide uses the locally installed Netpbm 11.5.2 build and takes about ten minutes. You need a PPM file and a shell. The examples write a new output file; they do not alter the input image.

1. Check the installed command

Confirm which executable will run and record its version information:

$ command -v ppmtopjxl
/usr/bin/ppmtopjxl
$ ppmtopjxl --version
ppmtopjxl: Using libnetpbm from Netpbm Version: 11.5.2

The version output includes build details after the library version. Exact diagnostic lines can differ between distributions, so the useful check is that the command identifies the Netpbm version rather than failing with an unknown option. If the command is missing, install the Netpbm package through your normal system package process before continuing; installing packages is outside this guide's examples and may need elevated privileges.

Checkpoint

Make sure the input is really PPM, not a PNG or JPEG with a misleading filename. A quick header check is read-only:

$ head -n 1 ./input.ppm
P3

P3 is an ASCII PPM header. A binary PPM may begin with P6. Both are PPM formats that Netpbm tools can read.

2. Convert one image to PCL

Choose an output path that does not contain a file you need, then redirect standard output to it:

$ ppmtopjxl ./input.ppm > ./output.pcl
ppmtopjxl: Computing colormap...
ppmtopjxl: ... Done.  256 colors found.
ppmtopjxl: Writing 8 bit color indices

The exact colour count and index width depend on the image. The PCL data is binary, so do not inspect it with a text editor, and do not expect useful terminal output if you print it directly. The optional ppmfile argument names the input; if you omit it, the command reads PPM data from standard input:

$ cat ./input.ppm | ppmtopjxl > ./output-from-stdin.pcl
$ wc -c ./output-from-stdin.pcl
68 ./output-from-stdin.pcl

Your byte count will differ. A non-zero exit status or an error about the input means the output may be incomplete. Treat the redirected file as untrusted until the command has succeeded.

3. Set a physical size

Use -xsize and -ysize when the printed dimensions matter. Their values are normally interpreted as dots, but you can append pt, dp, in or cm:

$ ppmtopjxl -xsize 6in -ysize 4in ./input.ppm > ./landscape.pcl
$ test -s ./landscape.pcl && printf '%s\n' 'created a non-empty PCL file'
created a non-empty PCL file

Specify only one dimension and ppmtopjxl scales the other proportionally, which is handy when you know the required width but want to keep the aspect ratio:

$ ppmtopjxl -width 5in ./input.ppm > ./five-inch-wide.pcl

-width and -height are synonyms for -xsize and -ysize. The -xscale and -yscale options take simple scale factors instead. Do not mix a physical dimension and a scale factor unless you have checked the result on a test page.

4. Choose rendering and placement options

The rendering switches select different ways to reduce the image's colours:

  • -dither selects ordered dithering.
  • -cluster selects clustered ordered dithering.
  • -diffuse selects error diffusion.

Try one at a time and compare test prints. These switches change rendering; they do not resize the source. For a darker background in an image being reduced, add -dark. For a quality-critical image, -presentation makes two passes over the paper to increase ink density: it costs more printing time and ink, so keep it for the final run rather than every preview.

Gamma correction is available with -gamma. The manpage describes approximately 0.6 to 1.5 as the useful range for a PaintJet XL:

$ ppmtopjxl -width 5in -gamma 1.2 -diffuse ./input.ppm > ./preview.pcl

Use -xshift and -yshift to move the image right and down. Measure the printer's printable area before relying on a shift near an edge: a shift can push part of an otherwise valid image off the page.

5. Verify the file before printing

Check that the conversion completed and the result is not empty:

$ ppmtopjxl -width 5in ./input.ppm > ./output.pcl
$ status=$?
$ printf 'conversion status: %s\n' "$status"
conversion status: 0
$ wc -c ./output.pcl
70 ./output.pcl

The size shown here is only an example from a tiny two-colour image; a real image will usually produce something different. You can inspect the first bytes without treating the file as text:

$ od -An -tx1 -N8 ./output.pcl
 1b 2a 72 32 73 31 54 1b

That header is evidence the output is PCL-like data, not proof a particular printer will accept it. The generated file targets an HP PaintJet XL. The manpage warns it is not suitable for a normal PaintJet printer.

6. Handle older PaintJet compatibility carefully

If you have a normal PaintJet rather than an XL, -nopack generates a file without the normal TIFF 4.0 compression method. The documented result might print on a normal PaintJet, but this is a compatibility attempt, not a guarantee:

$ ppmtopjxl -nopack ./input.ppm > ./unpacked.pcl
$ test -s ./unpacked.pcl

Warning

Do not overwrite a known-good PCL file while testing a different printer mode. Keep separate output names until a test page succeeds.

Recovery

If a test print fails, retain the source PPM, discard or rename the failed generated file, and return to the last command that produced a known-good file. No printer configuration is changed by ppmtopjxl itself.

Done means

  • You confirmed the installed Netpbm version and that the input is PPM.
  • You redirected ppmtopjxl output to a new file and checked its exit status.
  • You selected physical sizing, scaling, rendering and placement deliberately.
  • You kept binary PCL output out of text editors and terminals.
  • You know the normal output targets PaintJet XL hardware, with -nopack as a cautious normal PaintJet compatibility option.