LinuxCommandLibrary

pnmshear

Shear (slant) a portable bitmap image

TLDR

Shear a PNM image by the specified angle

$ pnmshear [angle] [path/to/input.pnm] > [path/to/output.pnm]
copy

Specify the color of the background in the sheared image
$ pnmshear [[-b|-background]] [blue] [angle] [path/to/input.pnm] > [path/to/output.pnm]
copy

Do not perform anti-aliasing
$ pnmshear [[-n|-noantialias]] [angle] [path/to/input.pnm] > [path/to/output.pnm]
copy

SYNOPSIS

pnmshear [-x Xshear] [-y Yshear] [pnmfile]

PARAMETERS

-x Xshear
    Specifies the amount of X-shearing. This is a floating-point number representing the horizontal shift for every unit change in the Y-coordinate. For example, a value of 0.5 means that for every pixel row, the horizontal position is shifted by half a pixel relative to the row above it.

-y Yshear
    Specifies the amount of Y-shearing. This is a floating-point number representing the vertical shift for every unit change in the X-coordinate. For example, a value of 0.5 means that for every pixel column, the vertical position is shifted by half a pixel relative to the column to its left.

pnmfile
    The path to the Portable Anymap (PNM) image file to be sheared. If not specified, pnmshear reads the image data from standard input.

DESCRIPTION

pnmshear is a Netpbm command-line utility for applying a shearing transformation to a Portable Anymap (PNM) image. Shearing skews an image along one axis, proportional to its position on the other axis.

For example, X-shearing shifts pixels horizontally based on their Y-coordinate, making the image appear to tilt. Similarly, Y-shearing shifts pixels vertically based on their X-coordinate. The command allows specifying the shear amount for both X and Y axes using floating-point numbers. The output image may be larger to accommodate the skewed shape, with newly exposed areas filled with black pixels.

CAVEATS

  • Shearing can significantly increase the dimensions of the output image, especially with large shear amounts, as the entire skewed shape must be contained.
  • Newly exposed areas outside the original image boundaries after shearing are filled with black pixels.
  • The transformation is pixel-based and may introduce jagged edges or loss of detail, particularly when the shear amount is not an integer multiple of pixel shifts.

INPUT/OUTPUT FORMATS

pnmshear exclusively operates on Portable Anymap (PNM) images, which include Portable Bitmap (PBM), Portable Graymap (PGM), and Portable Pixmap (PPM) formats. It reads PNM data from pnmfile or standard input and always outputs the resulting sheared image in PNM format to standard output. This design makes it suitable for use in pipelines with other Netpbm tools.

MATHEMATICAL CONCEPT OF SHEARING

A shear transformation shifts points in a direction parallel to a specific axis, with the amount of shift being proportional to the coordinate perpendicular to that axis. For an X-shear with factor s_x, a point (x, y) transforms to (x + s_x * y, y). For a Y-shear with factor s_y, (x, y) transforms to (x, y + s_y * x). pnmshear applies these transformations to the pixel coordinates of the image.

HISTORY

pnmshear is a component of the Netpbm project, a widely used suite of graphics manipulation tools for Unix-like systems. Netpbm originated from the pbmplus package developed by Jef Poskanzer in the late 1980s, which itself was based on earlier pbm utilities. Over decades, Netpbm has evolved as a collection of converters and filters for various graphics formats, with pnmshear being one of the specialized filters added to perform geometric transformations on the intermediary PNM formats (PBM, PGM, PPM). Its development aligns with the Netpbm philosophy of providing small, single-purpose tools that can be chained together using pipes.

SEE ALSO

pnm(5), pnmrotate(1), pnmflip(1), pnmscale(1), pnmcrop(1)

Copied to clipboard