This is documentation for Mathematica 7, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

ImageCrop

ImageCrop[image]
crops image by removing borders of uniform color.
ImageCrop[image, {w, h)]
crops image to pixel width w and pixel height h.
ImageCrop[image, size]
crops image based on the size specification size.
ImageCrop[image, size, spec]
crops image by removing pixels from sides specified by spec.
  • ImageCrop[image] effectively starts at the borders of image, then removes as many layers of pixels as possible where all their color values exactly match the colors of the borders.
  • ImageCrop[image, {w, h}] by default removes pixels symmetrically from image, or if w or h is larger than for image, it adds pixels symmetrically.
  • The final image size specification size in ImageCrop[image, size] can have following forms:
{w,h}particular width and height
wwidth w; height based on aspect ratio
{s}maximum width or height s
{{wmax},{hmax}}width and height maximums
{{wmin,wmax},{hmin,hmax}}width and height ranges
  • The following special forms can be used for width or height:
Fulldo no cropping in this dimension
Automaticdetermine value from aspect ratio
  • 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
  • Cropping fractions are between -1 and +1. In the horizontal case, -1 is equivalent to Left, +1 to Right, and 0 to Center. In the vertical case, -1 is equivalent to Bottom, and +1 to Top.
  • The following options can be given:
AspectRatioAutomaticratio of height to width for the final image
PaddingBlackpadding to use if necessary
Automaticuse the aspect ratio of the original image
ruse aspect ratio r
  • If the final image specified by ImageCrop[image, ...] extends beyond image, then pixels are added according to the setting for Padding.
Automatically crop uniform borders:
Crop an image to a 100 by 100 pixels:
Crop to a width of 100 pixels and a height of 50 pixels:
Crop at the left side:
Crop at the left and the bottom side:
Padding is used if a size larger than the original size is specified:
Automatically crop uniform borders:
In[1]:=
Click for copyable input
Out[1]=
 
Crop an image to a 100 by 100 pixels:
In[1]:=
Click for copyable input
Out[1]=
 
Crop to a width of 100 pixels and a height of 50 pixels:
In[1]:=
Click for copyable input
Out[1]=
 
Crop at the left side:
In[1]:=
Click for copyable input
Out[1]=
 
Crop at the left and the bottom side:
In[1]:=
Click for copyable input
Out[1]=
 
Padding is used if a size larger than the original size is specified:
In[1]:=
Click for copyable input
Out[1]=
Pad an image to a fixed size:
New in 7