LinuxCommandLibrary

pbmreduce

Reduce the size of a PBM image

TLDR

Reduce the specified image by the specified factor

$ pbmreduce [n] [path/to/image.pbm] > [path/to/output.pbm]
copy

Use simple thresholding when reducing
$ pbmreduce [[-t|-threshold]] [n] [path/to/image.pbm] > [path/to/output.pbm]
copy

Use the specified threshold for all quantizations
$ pbmreduce [[-va|-value]] [0.6] [n] [path/to/image.pbm] > [path/to/output.pbm]
copy

SYNOPSIS

pbmreduce [pbmfile]

DESCRIPTION

pbmreduce is a utility from the Netpbm package designed to reduce the dimensions of a portable bitmap (PBM) image. It reads a PBM image as input and produces a new PBM image that is half the width and half the height of the original.

The reduction process works by considering each 2x2 square of pixels in the input image and replacing it with a single pixel in the output image. The value of this new pixel is determined by an 'OR' logic: it becomes 1 (black) if any of the four original pixels in the 2x2 square were 1 (black); otherwise, it remains 0 (white).

This command is particularly useful for quickly generating thumbnails or downscaled versions of binary images. It's a simple, fast way to halve the resolution of PBM files. If the input image's dimensions are not exact multiples of 2, any extra rows or columns on the right or bottom edges are simply dropped.

CAVEATS

Any rows or columns in the input image that extend beyond an exact multiple of 2 in width or height are truncated (dropped) from the output.

INPUT AND OUTPUT

If pbmfile is not specified, pbmreduce reads the PBM image from standard input. The resulting reduced image is always written to standard output.

PIXEL REDUCTION LOGIC

For every 2x2 block of pixels from the input image, pbmreduce creates a single pixel in the output. This output pixel is black (1) if at least one of the four input pixels was black. Otherwise, it is white (0). This effectively performs a logical OR operation on the pixel values.

HISTORY

pbmreduce is a standard utility included as part of the Netpbm package. Netpbm is a venerable collection of graphics programs and a programming library, originally developed from PBMplus. It provides fundamental tools for manipulating various image formats, with pbmreduce serving as a basic but effective command for image downsizing.

SEE ALSO

pbm(5), pbmscale(1)

Copied to clipboard