LinuxCommandLibrary

pamflip

Flip a PAM image vertically or horizontally

TLDR

Rotate the input image counter-clockwise for a specific degree

$ pamflip [[-r|-rotate]][90|180|270] [path/to/input.pam] > [path/to/output.pam]
copy

Flip left for right
$ pamflip [[-lr|-leftright]] [path/to/input.pam] > [path/to/output.pam]
copy

Flip top for bottom
$ pamflip [[-tb|-topbottom]] [path/to/input.pam] > [path/to/output.pam]
copy

Flip the input image on the main diagonal
$ pamflip [[-xy|-transpose]] [path/to/input.pam] > [path/to/output.pam]
copy

SYNOPSIS

pamflip {-horiz | -vert | -lr | -tb} [file]

PARAMETERS

-horiz
    Flips the image horizontally (left-to-right).

-vert
    Flips the image vertically (top-to-bottom).

-lr
    An alias for -horiz, also flips the image horizontally.

-tb
    An alias for -vert, also flips the image vertically.

DESCRIPTION

pamflip is a utility from the Netpbm suite of graphics tools, designed specifically for manipulating Portable Anymap (PAM) images. Its primary function is to flip an image along either its horizontal or vertical axis. When flipping horizontally, the image is mirrored left-to-right, effectively reversing the order of pixels in each row. When flipping vertically, the image is mirrored top-to-bottom, reversing the order of rows.

This command operates as a filter, meaning it typically reads an image from standard input and writes the flipped image to standard output. This allows it to be easily integrated into shell pipelines, chaining with other Netpbm utilities for complex image processing tasks.

pamflip can handle all Netpbm formats (PBM, PGM, PPM, and PAM) as input, automatically converting them to the PAM format internally for processing, then outputting the result in PAM format. It is a fundamental tool for basic image manipulation within the Netpbm ecosystem.

CAVEATS

pamflip can only perform one type of flip (horizontal or vertical) per invocation. To perform both a horizontal and vertical flip, you must pipe the output of one pamflip command to another. For example, pamflip -horiz | pamflip -vert. It does not support arbitrary rotations or other transformations.

USAGE EXAMPLES

To flip an image named input.pam horizontally and save it as output_h.pam:
pamflip -horiz input.pam > output_h.pam

To flip an image read from a pipeline vertically:
convert image.jpg pgm:- | pamflip -vert > flipped.pam

To flip an image both horizontally and vertically:
pamflip -horiz input.pam | pamflip -vert > output_hv.pam

INPUT AND OUTPUT

pamflip primarily works as a filter. If no input file is specified, it reads a PAM image from standard input. The resulting flipped PAM image is always written to standard output. This design allows for seamless integration into complex shell scripts and pipelines for image manipulation.

HISTORY

pamflip is part of the Netpbm project, which originated from the Pbmplus package developed by Jef Poskanzer in the late 1980s. The Netpbm suite evolved to include more robust and unified tools under the Portable Anymap (PAM) format specification. pamflip was introduced as a modern equivalent or successor to pnmflip, designed to uniformly handle all Netpbm image types (PBM, PGM, PPM, and the newer PAM format) via the versatile PAM interface. Its development reflects the Netpbm project's goal of providing a comprehensive, modular toolkit for image processing in a Unix-like environment.

SEE ALSO

netpbm(1), pam(5), pnmflip(1), pamrotate(1), pnmrotate(1)

Copied to clipboard