Home / Alt manpages / ppmwheel(1)

  • ppmwheel(1)
  • User command
  • linux

Generate PPM Colour Wheels with ppmwheel

ppmwheel draws a colour wheel in one shell command, sized exactly how you want it. It writes plain PPM data with nothing else running behind the scenes, in one of three layouts. The examples use Netpbm 11.5.2, from the Debian package netpbm 2:11.05.02-1.1build1.

Ten minutes gets you through it. You need a shell, ppmwheel from Netpbm, and a little disk space for the output. No elevated privileges, no system configuration touched: this only writes new files, and only overwrites an existing one if you deliberately point it there.

1. Check the installed command

Confirm which executable will run and note the local Netpbm build. It is a read-only check, so there is nothing to be careful about:

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

Build details trail after the library version, so your own output may run a line or two longer. The installed manpage describes ppmwheel as taking one non-option argument: the wheel's diameter in pixels. That same number becomes the output image's width and height.

Checkpoint

If command -v comes back empty, install Netpbm through your distribution's normal package process and repeat the check. Do not copy a binary over from another machine just to get the example running.

2. Generate the default wheel

Pick a size and redirect the binary PPM stream into a new file. This one makes a 120 by 120 image:

$ ppmwheel 120 > /tmp/colour-wheel.ppm
$ file /tmp/colour-wheel.ppm
/tmp/colour-wheel.ppm: Netpbm image data, size = 120 x 120, rawbits, pixmap

The default follows the old Ppmcirc-style wheel: full saturation, and a value curve that is deliberately a bit unusual, inherited from the ppmcirc programme it came from. It sits inside a white square rather than a transparent circle, and the format is PPM, normally with a maximum channel value of 255.

PPM is a handy format for passing images between tools, but it is rarely the right one for a finished web image. Convert a copy rather than the source, if you have a converter to hand:

$ magick /tmp/colour-wheel.ppm /tmp/colour-wheel.png

No magick installed? Keep the PPM file, or reach for whatever image tool is already approved on your system. ppmwheel itself never writes PNG or JPEG.

3. Choose a hue-value or hue-saturation layout

Use -huevalue for saturation fixed at 100% and value climbing from a black centre out towards the edge:

$ ppmwheel 512 -huevalue > /tmp/hue-value-wheel.ppm
$ identify /tmp/hue-value-wheel.ppm
/tmp/hue-value-wheel.ppm PPM 512x512 512x512+0+0 8-bit sRGB ...

Use -huesaturation for value fixed at 100% and saturation climbing from a white centre out towards the edge:

$ ppmwheel 512 -huesaturation > /tmp/hue-saturation-wheel.ppm
$ identify /tmp/hue-saturation-wheel.ppm
/tmp/hue-saturation-wheel.ppm PPM 512x512 512x512+0+0 8-bit sRGB ...

The two names are easy to mix up on a bad day. Black centre means hue-value; white centre means hue-saturation. Both landed in Netpbm 10.86, so they are present in the installed 11.5.2 build here.

identify is used above only for inspection. Without ImageMagick, read the PPM header directly:

$ head -n 3 /tmp/hue-value-wheel.ppm
P6
512 512
255

P6 means binary PPM. The first three header lines give you format, dimensions and maximum channel value; raw pixel data follows.

4. Control the channel range

255 is the default maximum channel value. Set another with -maxval=N, where N lands straight in the PPM header:

$ ppmwheel 120 -huesaturation -maxval=15 > /tmp/hue-saturation-15.ppm
$ head -n 3 /tmp/hue-saturation-15.ppm
P6
120 120
15

A lower maximum can suit a consumer expecting a narrower sample range, but it costs precision. Stick with 255 unless the next tool in your pipeline explicitly demands otherwise, and treat N as a plain number, not a quoted label such as MAXVAL.

A file existing is not proof the command succeeded. Check the exit status and header together:

$ ppmwheel 256 -huevalue > /tmp/check-wheel.ppm
$ status=$?
$ printf 'ppmwheel status: %s\n' "$status"
ppmwheel status: 0
$ head -n 3 /tmp/check-wheel.ppm
P6
256 256
255

5. Dodge the common mistakes

Leaving off the diameter is an error: ppmwheel needs exactly one non-option argument. Start with ppmwheel 120, not bare ppmwheel. Keep the size sensible; a huge image eats memory and disk space without improving a small display.

Redirection is where people get bitten. The shell opens the destination before ppmwheel even starts, so a typo can leave an empty file behind, and a real destination can get truncated. Check the path first:

$ test ! -e /path/to/output.ppm && echo 'destination is unused'
destination is unused
$ ppmwheel 120 > /path/to/output.ppm

If you did overwrite something, ppmwheel has no undo. Pull it back from a backup, version control or the source image. For routine experiments, work under a new path in /tmp or a dedicated directory, then clean up with your normal process once you have confirmed which files are safe to remove.

None of this is persistent, either. Changing the wheel type or maxval changes the generated data, not some lingering Netpbm setting. Every invocation starts fresh: no configuration file to edit, no service to restart.

Done means

  • ppmwheel resolves to the expected Netpbm installation.
  • You chose a diameter and produced a PPM with matching width and height.
  • You selected the default, hue-value or hue-saturation layout deliberately.
  • The PPM header shows the expected P6, dimensions and maximum value.
  • You kept generated files separate from originals and know how to recover an accidental overwrite.