---
title: "cropped(to:)"
framework: coreimage
role: symbol
role_heading: Instance Method
path: "coreimage/ciimage/cropped(to:)"
---

# cropped(to:)

Returns a new image with a cropped portion of the original image.

## Declaration

```swift
func cropped(to rect: CGRect) -> CIImage
```

## Parameters

- `rect`: The rectangle, in image coordinates, to which to crop the image.

## Return Value

Return Value An image object cropped to the specified rectangle.

## Discussion

Discussion

Discussion Due to Core Image’s coordinate system mismatch with UIKit, this filtering approach may yield unexpected results when displayed in a UIImageView with contentMode. Be sure to back it with a cgImage so that it handles contentMode properly. CIContext* context = [CIContext context]; CGImageRef cgCroppedImage = [context createCGImage:ciCroppedImage fromRect:ciCroppedImage.extent]; UIImage* croppedImage = [UIImage imageWithCGImage:cgCroppedImage]; CGImageRelease(cgCroppedImage); If you are displaying or processing your image primarily as a CGImage or UIImage, with no additional Core Image application, consider cropping in Core Graphics using the cropping(to:) function to save processing overhead from conversion of images to CIImage.  It makes most sense to use cropped(to:) when you already have CIImage in your pipeline.

## See Also

### Creating an Image by Modifying an Existing Image

- [applyingFilter(_:parameters:)](coreimage/ciimage/applyingfilter(_:parameters:).md)
- [applyingFilter(_:)](coreimage/ciimage/applyingfilter(_:).md)
- [transformed(by:)](coreimage/ciimage/transformed(by:).md)
- [transformed(by:highQualityDownsample:)](coreimage/ciimage/transformed(by:highqualitydownsample:).md)
- [oriented(forExifOrientation:)](coreimage/ciimage/oriented(forexiforientation:).md)
- [clampedToExtent()](coreimage/ciimage/clampedtoextent().md)
- [clamped(to:)](coreimage/ciimage/clamped(to:).md)
- [composited(over:)](coreimage/ciimage/composited(over:).md)
- [convertingWorkingSpaceToLab()](coreimage/ciimage/convertingworkingspacetolab().md)
- [convertingLabToWorkingSpace()](coreimage/ciimage/convertinglabtoworkingspace().md)
- [matchedToWorkingSpace(from:)](coreimage/ciimage/matchedtoworkingspace(from:).md)
- [matchedFromWorkingSpace(to:)](coreimage/ciimage/matchedfromworkingspace(to:).md)
- [premultiplyingAlpha()](coreimage/ciimage/premultiplyingalpha().md)
- [unpremultiplyingAlpha()](coreimage/ciimage/unpremultiplyingalpha().md)
- [settingAlphaOne(in:)](coreimage/ciimage/settingalphaone(in:).md)
