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

ImageCrop

ImageCrop[image]
crops image by removing borders of uniform color.
ImageCrop
crops image to pixel width w and pixel height h.
ImageCrop
crops image based on the size specification size.
ImageCrop
crops image by removing pixels from sides specified by spec.
  • ImageCrop[image] effectively removes borders from image whose pixel value distribution is almost uniform.
  • ImageCrop 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 can have the 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 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 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.
  • 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
  • An explicit setting for AspectRatio is only taken into account when either the height or width is not specified.
  • If the final image specified by ImageCrop extends beyond image, then pixels are added according to the setting for Padding.
Automatically crop uniform borders:
Crop an image to 100 by 100 pixels:
Crop to a width of 100 pixels and a height of 50 pixels:
Crop at the left side, preserving the aspect ratio:
Crop at the left side only:
Crop at the left side and the bottom:
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 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, preserving the aspect ratio:
In[1]:=
Click for copyable input
Out[1]=
 
Crop at the left side only:
In[1]:=
Click for copyable input
Out[1]=
 
Crop at the left side and the bottom:
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:
Letterbox a wide image into a 320×240 format:
New in 7