Home / Alt manpages / ppmwheel(1)

  • ppmwheel(1)
  • User command
  • linux

Generate PPM Colour Wheels with ppmwheel

You will finish with a reproducible PPM colour wheel, sized in pixels and selected from one of three layouts. The examples use Netpbm 11.5.2, installed from the Debian package netpbm 2:11.05.02-1.1build1.

Allow about ten minutes. You need a shell, ppmwheel from Netpbm, and enough disk space for the generated image. No elevated privileges are needed. This guide writes new files only; it does not alter system configuration or replace an existing image unless you deliberately choose its path.

1. Check the installed command

Confirm which executable will run and record the local Netpbm build. This is an ordinary read-only check:

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

The version output includes build details after the library version, so the exact trailing lines may differ. The installed manpage describes the command as taking one non-option argument, the wheel's diameter in pixels. That value is also the output image's width and height.

Checkpoint

If command -v prints nothing, install Netpbm using your distribution's normal package process, then repeat this check. Do not copy a binary from an unrelated host just to make the example run.

2. Generate the default wheel

Choose a size and redirect the binary PPM stream into a new file. This example creates 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 is the historical Ppmcirc-style wheel. It uses full saturation and a deliberately unusual value curve inherited from the ppmcirc programme. The wheel sits inside a white square, so the output is not a transparent circle. The output format is PPM, normally with a maximum channel value of 255.

PPM is a useful interchange format, but it is not usually the best format for a finished web image. If you have an image conversion tool available, convert a copy rather than overwriting the source:

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

If magick is not installed, keep the PPM file or use the image tools already approved for your system. The ppmwheel command itself does not write PNG or JPEG.

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

Use -huevalue when you want saturation fixed at 100% and value to increase from the black centre 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 when value is fixed at 100% and saturation increases from a white centre 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 option names are easy to mix up. A black centre indicates the hue-value variant; a white centre indicates hue-saturation. Both options were added in Netpbm 10.86, so they are available in the installed 11.5.2 build.

The sample uses ImageMagick's identify only for inspection. If it is absent, verify the PPM header directly:

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

P6 means a binary PPM. The first three header lines show the format, dimensions and maximum channel value; binary pixel data follows them.

4. Control the channel range

The default maximum channel value is 255. Set another value with -maxval=N, where N is the value written into 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 be useful when a consumer expects a smaller sample range, but it also reduces available precision. Keep 255 unless the next tool in your pipeline explicitly requires another range. Treat N as a number, not a quoted label such as MAXVAL.

Do not assume a command succeeded merely because a file exists. 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. Avoid common mistakes and recover safely

A missing diameter is an error: the command requires exactly one non-option argument. Start with ppmwheel 120, not just ppmwheel. Use a positive, practical size; very large images consume memory and disk space without improving a small display.

Place redirection carefully. The shell opens the destination before starting ppmwheel, so a typo can create an empty file, and an existing destination can be truncated. Before using a real path, inspect it:

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

If you overwrote a file, ppmwheel has no undo operation. Recover from your backup, version control or the source image. For routine experiments, use a new path under /tmp or a dedicated working directory, then remove unwanted files with your normal cleanup process after checking that they are the correct files.

Remember that changing the wheel type or maxval changes the generated data, not a persistent Netpbm setting. Each invocation is independent. There is no configuration file to edit and 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.