Home / Alt manpages / ppmspread(1)

  • ppmspread(1)
  • User command
  • linux

Soften a PPM Image with Repeatable Pixel Spreading

A crisp photo can look too clinical for a mood board, and ppmspread fixes that. It nudges every pixel by a small random amount, giving the image a dissolved, unfocussed look. The examples use ppmspread from Netpbm 11.05.02, the version installed on this machine. Allow about ten minutes if your source is already a PPM, longer if you first need to convert another format.

You need a shell, a readable PPM input, and enough free space for a second image. The command reads the input and writes a new PPM to standard output, it never edits the source, and normally needs no elevated privileges.

1. Check the input before transforming it

Pick an input file and check its type and dimensions:

$ file source.ppm
source.ppm: Netpbm image data, size = 1920 x 1080, rawbits, pixmap
$ test -r source.ppm && echo readable
readable

The exact wording from file can vary. What matters is that the file is PPM and its dimensions match what you expect. PPM can be ASCII or raw binary, and ppmspread reads the image rather than trusting a filename extension, so do not assume renaming another format is enough.

Checkpoint

Keep source.ppm untouched. If you need a PPM from a PNG, JPEG or anything else, convert it with a separate tool first and verify that converter's output before running this guide.

2. Spread pixels by a small amount

Pass the maximum movement as the first argument and redirect the result to a new filename:

$ ppmspread 3 source.ppm > spread-3.ppm
$ file spread-3.ppm
spread-3.ppm: Netpbm image data, size = 1920 x 1080, rawbits, pixmap

The 3 means each pixel may move by at most three pixels from its original position, a maximum displacement, not a percentage, a blur radius or an output size. Raise it for a stronger dissolved effect, then compare against the source in a viewer. Small values are usually easier to judge because the image stays recognisable.

ppmspread writes image data to standard output, so the redirect is not optional decoration, without > spread-3.ppm the binary result lands on your terminal. Feed that output into another Netpbm program instead if you are building a pipeline.

3. Protect an existing destination

Do not redirect straight over a file you care about while experimenting, redirection truncates its destination before ppmspread has finished. Use a new name, or take a backup before replacing anything:

$ cp --preserve=all spread-3.ppm spread-3.ppm.bak
$ ppmspread 5 source.ppm > spread-3.ppm.new
$ file spread-3.ppm.new
spread-3.ppm.new: Netpbm image data, size = 1920 x 1080, rawbits, pixmap
$ mv spread-3.ppm.new spread-3.ppm

The mv is the only state-changing step here. It replaces the old destination only once the new command has completed and you have checked the output. If the transformation fails, inspect or remove the incomplete spread-3.ppm.new, the original and its backup stay put. Once you accept the result, remove the backup as a separate, deliberate cleanup step.

Warning

Do not reach for sudo just because an image tool is involved. Run the command as your normal user when the input and output directories are yours. Use elevated access only if your system genuinely requires it, and prefer copying the image into a writable working directory instead.

4. Make a result reproducible

By default the pixel movement is random. Add -randomseed= followed by an integer when a later run needs to produce the same output:

$ ppmspread 3 source.ppm -randomseed=42 > spread-seed-42-a.ppm
$ ppmspread 3 source.ppm -randomseed=42 > spread-seed-42-b.ppm
$ cmp -s spread-seed-42-a.ppm spread-seed-42-b.ppm && echo identical
identical

The option seeds the generator used for the pixel movement. Keep the amount, input bytes, Netpbm version and seed unchanged and you get a repeatable file; a different seed is expected to produce a different arrangement. The option arrived in Netpbm 10.94, so it is present in this 11.05.02 build but may be missing on much older installs.

For a one-off visual effect, skip the option entirely. For a build, test fixture or documented asset, record the seed alongside the command. It buys repeatability, nothing more, it does not make the transformation cryptographically random or protect image data.

5. Diagnose a disappointing result

If the command cannot open the input, check the path and permissions without touching the image:

$ ls -l source.ppm
$ test -r source.ppm && echo readable
readable

If the output is not what you expected, first confirm you actually opened the new file and not the original. Then compare dimensions with file: ppmspread moves pixel positions, it does not resize the image or convert PPM to PNG, JPEG or anything else. Convert the verified PPM separately if you need a compressed delivery format.

A successful exit status only tells you the command completed, not that the visual strength suits the job. Inspect the output and keep the source until you are satisfied. If a viewer rejects the result, check the redirection completed and that the output starts with a valid PPM header, then rerun to a fresh filename rather than overwriting your last good result.

Done means

  • Source unchanged: the input PPM was readable and stayed untouched.
  • Displacement chosen: the first argument supplied the maximum pixel movement you intended.
  • Output checked: the result was redirected to a new file and verified before any replacement.
  • Repeatable if needed: -randomseed=42, or another recorded integer, was used when repeatability mattered.
  • Visually confirmed: the final PPM has the expected dimensions and has been inspected.