# pnmcrop(1) - man - phpman

> **TLDR:** Crop PNM images.
>
- Remove white borders on a PNM image:
  `pnmcrop {{-w|-white}} {{path/to/image.pnm}} > {{path/to/output.pnm}}`
- Remove borders of the specified color that are on the top and left side of the image:
  `pnmcrop -bg-color {{color}} {{-t|-top}} {{-l|-left}} {{path/to/image.pnm}} > {{path/to/output.pnm}}`
- Determine the color of the borders to be removed by the color of the pixel in the specified corner:
  `pnmcrop -bg-corner {{topleft|topright|bottomleft|bottomright}} {{path/to/image.pnm}} > {{path/to/output.pnm}}`
- Leave a border with a width of `n` pixels. Additionally, specify the behavior if the image is entirely made out of background:
  `pnmcrop {{-m|-margin}} {{n}} {{-blan|-blank-image}} {{pass|minimize|maxcrop}} {{path/to/image.pnm}} > {{path/to/output.pnm}}`

*Source: tldr-pages*

---

[pnmcrop(1)](https://www.chedong.com/phpMan.php/man/pnmcrop/1/markdown)                             General Commands Manual                            [pnmcrop(1)](https://www.chedong.com/phpMan.php/man/pnmcrop/1/markdown)



## NAME
       pnmcrop - crop a portable anymap

## SYNOPSIS
       **pnmcrop** [**-white**|**-black**|**-sides**] [**-left**] [**-right**] [**-top**] [**-bottom**] [_pnmfile_]

       All  options  may be abbreviated to their shortest unique prefix or specified with double hy‐
       phens.


## DESCRIPTION
       Reads a PBM, PGM, or PPM image as input.  Removes borders that are the background color,  and
       produces the same type of image as output.

       If  you  don't  specify otherwise, **pnmcrop** assumes the background color is whatever color the
       top left and right corners of the image are and if they are different colors, something  mid‐
       way  between them.  You can specify that the background is white or black with the **-white** and
### -black
### -sides

       By  default,  **pnmcrop**  chops  off any stripe of background color it finds, on all four sides.
       You can tell **pnmcrop** to remove only specific borders with the **-left**, **-right**, **-top**, and  **-bot**‐‐
       **tom** options.

       If you want to chop a specific amount off the side of an image, use **pnmcut**.

       If you want to add different borders after removing the existing ones, use **pnmcat** or **pnmcomp**.


## OPTIONS
### -white

### -black

### -sides
              **pnmcrop** removes borders which are of the background color.

              If at least three of the four corners are the same color, **pnmcrop** takes  that  as  the
              background color.  If not, **pnmcrop** looks for two corners of the same color in the fol‐
              lowing order, taking the first found as the background color: top, left,  right,  bot‐
              tom.  If all four corners are different colors, **pnmcrop** assumes an average of the four
              colors as the background color.

              The **-sides** option slows **pnmcrop** down, as it reads the entire image  to  determine  the
              background  color  in  addition to the up to three times that it would read it without
              **-sides**.


### -left

### -right

### -top

### -bottom
              Remove any bottom border.

### -verbose
              Print on Standard Error information about the processing, including exactly  how  much
              is being cropped off of which sides.



## SEE ALSO
       [**pnmcut**(1)](https://www.chedong.com/phpMan.php/man/pnmcut/1/markdown), [**pnmfile**(1)](https://www.chedong.com/phpMan.php/man/pnmfile/1/markdown), [**pnm**(5)](https://www.chedong.com/phpMan.php/man/pnm/5/markdown)


## AUTHOR
       Copyright (C) 1989 by Jef Poskanzer.



                                            18 March 2001                                 [pnmcrop(1)](https://www.chedong.com/phpMan.php/man/pnmcrop/1/markdown)
