Wolfram Computation Meets Knowledge

Wolfram Language & System Documentation Center Wolfram Language Home Page »

ImageCrop

ImageCrop[image]

crops image by removing borders of uniform color.

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[video,…]

crops frames of video.

Details and Options

Examples

open allclose all

Basic Examples  (2)

Automatically crop uniform borders:

Crop an image to a given size:

Scope  (7)

Data  (3)

Crop a 2D image:

Crop frames of a video:

Crop constant areas of a 3D image:

Size Specification  (2)

Crop an image to a width of 100 pixels, preserving the aspect ratio:

Crop to a 100×100 pixel square:

Do not crop the height of the image:

Crop to a height of 100 pixels, preserving the aspect ratio:

Make the largest dimension not greater than 100 pixels:

Pad the image by using values greater than the image dimensions:

Crop a 3D image:

Crop a 3D image in the vertical dimension only:

Side Specification  (2)

Crop on the left side, preserving the aspect ratio:

Crop at the left side, using numerical values:

Crop evenly from both sides using numerical values:

Crop from the left and bottom sides:

Crop a 3D image:

Crop the top 23 slices off a 3D image:

Extract a selected horizontal slice of a 3D image:

Take all slices in a selected region of the 3D image:

Options  (2)

Padding  (2)

By default, black padding is used:

Pad the image with a specified color:

Specify a different padding scheme:

Use Padding->None to avoid padding:

The result may be smaller than the given size:

With Padding->Automatic, a color based on the boundary pixel values is chosen:

If the boundary pixels do not have consistent colors, black is used:

Applications  (1)

Letterbox a wide image into a 320×240 format:

Properties & Relations  (3)

ImageCrop preserves the aspect ratio of the image:

Use ImageTake to crop an image:

ImageCrop adds or removes pixels on the sides to achieve specified output dimensions:

Use ImagePad to add or remove specified numbers of pixels on the sides:

Possible Issues  (2)

Cropping happens if a similar border is present on at least two sides:

If a border is present only on one side, it is not cropped:

Detect the border using BorderDimensions and crop it using ImagePad:

Wolfram Research (2008), ImageCrop, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageCrop.html (updated 2021).

Text

Wolfram Research (2008), ImageCrop, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageCrop.html (updated 2021).

CMS

Wolfram Language. 2008. "ImageCrop." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImageCrop.html.

APA

Wolfram Language. (2008). ImageCrop. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageCrop.html

BibTeX

@misc{reference.wolfram_2024_imagecrop, author="Wolfram Research", title="{ImageCrop}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImageCrop.html}", note=[Accessed: 18-May-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_imagecrop, organization={Wolfram Research}, title={ImageCrop}, year={2021}, url={https://reference.wolfram.com/language/ref/ImageCrop.html}, note=[Accessed: 18-May-2024 ]}

Top