crops image by removing borders of uniform color.


crops image based on the size specification size.


crops image by removing pixels from sides specified by spec.

Details and Options

  • Image cropping, also known as image trimming, is the process of removing border pixels from an image and can be used for removing uninteresting regions or extracting regions of interest.
  • ImageCrop[image] effectively removes borders from image whose pixel value distribution is almost uniform.
  • ImageCrop[image,{width,height}] by default removes pixels symmetrically from image, or if width or height is larger than for image, it adds pixels symmetrically.
  • The image size specification size in ImageCrop[image,size] can have the following forms:
  • widthparticular width; height based on aspect ratio
    {width,height}particular width and height
    {width,depth,height}particular width, depth and height in 3D
  • Specifications for either of the dimensions can be any of the following:
  • dd pixels
    UpTo[d]maximum d pixels
    {dmin,dmax}pixel ranges
    Automaticdetermine value from aspect ratio
    Fulldo no cropping in this dimension
  • The cropping specification spec in ImageCrop[image,size,spec] can have the following forms:
  • sidecrop on the specified side; center otherwise
    {side1,side2}crop on the specified sides
    {ax,ay}assign a fraction of cropping to each side
  • Sides can be specified as Left, Right, Bottom or Top. Center indicates symmetrical cropping.
  • Cropping fractions are between and . In the horizontal case, is equivalent to Left, to Right and to Center. In the vertical case, is equivalent to Bottom, and to Top.
  • ImageCrop[image,size] is equivalent to ImageCrop[image,size,Center].
  • To obtain an image with an aspect ratio r, use ImageCrop[image,width{1,r}].
  • If the final image specified by ImageCrop[image,] extends beyond image, then pixels are added according to the setting for Padding.


open all close all

Basic Examples  (2)

Automatically crop uniform borders:

Click for copyable input

Crop an image to a given size:

Click for copyable input

Scope  (6)

Options  (2)

Applications  (1)

Properties & Relations  (3)

Possible Issues  (2)

Introduced in 2008
Updated in 2015