LinuxCommandLibrary

pnmflip

Flip a PNM image

TLDR

View documentation for the current command

$ tldr pamflip
copy

SYNOPSIS

pnmflip [-lr] [-tb] [-r90|-r180|-r270] [pnmfile]

PARAMETERS

-lr
    Flips the image left-to-right (horizontally mirrors it).

-tb
    Flips the image top-to-bottom (vertically mirrors it).

-r90
    Rotates the image 90 degrees clockwise.

-r180
    Rotates the image 180 degrees.

-r270
    Rotates the image 270 degrees clockwise (equivalent to 90 degrees counter-clockwise).

pnmfile
    The path to the input PNM image file. If omitted, pnmflip reads the image data from standard input.

DESCRIPTION

pnmflip is a versatile command-line utility from the Netpbm suite, designed for fundamental transformations of Portable Anymap (PNM) images. It allows users to easily flip images horizontally or vertically, and rotate them by 90, 180, or 270 degrees clockwise. This tool operates as a filter, typically reading a PNM image from standard input and writing the modified image to standard output, making it highly suitable for use in shell pipelines. For instance, you can pipe the output of an image conversion tool directly into pnmflip and then pipe its output to another Netpbm utility or a display program. Its simplicity and robust integration within the Netpbm ecosystem make it an essential utility for basic image orientation adjustments in scripting and batch processing workflows. While pnmflip handles common transformations, it strictly works with PBM, PGM, and PPM formats, upholding the modular design philosophy of the Netpbm toolkit.

CAVEATS

pnmflip only works with Portable Anymap (PBM, PGM, PPM) formats.
Rotation options (-r90, -r180, -r270) are mutually exclusive; you can only specify one at a time.
If both flip (-lr or -tb) and rotate options are specified, the flips are applied before the rotations.

STANDARD INPUT/OUTPUT

pnmflip is designed to operate as a filter. By default, it reads image data from standard input (stdin) and writes the processed image to standard output (stdout). This makes it highly flexible for use in pipelines, allowing it to be chained with other Netpbm utilities or command-line tools without needing intermediate files. For example: `convert input.jpg pnm:- | pnmflip -r90 | pnmtojpeg > output_rotated.jpg`.

FORMAT SUPPORT

The command specifically supports the Portable Anymap formats: PBM (Portable Bitmap for monochrome images), PGM (Portable Graymap for grayscale images), and PPM (Portable Pixmap for color images). It cannot directly process other image formats like JPEG, PNG, or GIF; these must first be converted to a PNM format using other Netpbm tools (e.g., `jpegtopnm`, `pngtopnm`) before being processed by pnmflip.

HISTORY

`pnmflip` is a long-standing utility within the Netpbm suite, which evolved from the Pbmplus package created by Jef Poskanzer. It has been a core component for basic image manipulation on Unix-like systems since the early days of graphical computing. Its design philosophy aligns with the Unix principle of small, focused tools that do one thing well and can be combined via pipes. While newer, more generalized tools like pamflip exist within Netpbm, pnmflip remains widely used for its specific PNM-centric functionality and backward compatibility.

SEE ALSO

netpbm(1), pnm(5), pamflip(1), pnmrotate(1)

Copied to clipboard