<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIFilter-swift.class/stretchCrop()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIFilter(cm)stretchCropFilter"
  },
  "title" : "stretchCrop()"
}
-->

# stretchCrop()

Distorts an image by stretching or cropping to fit a specified size.

```
class func stretchCrop() -> any CIFilter & CIStretchCrop
```

## Return Value

The distorted image.

## Discussion

This method applies the stretch crop filter to an image. This effect distorts an image by stretching an image and then applies the crop extent. If the crop value is 0, the filter only uses stretching. If the value is 1, then the filter only uses cropping.

The stretch crop filter uses the following properties:

- `inputImage`: An image with the type [`CIImage`](/documentation/CoreImage/CIImage).
- `centerStretchAmount`: A `float` representing the amount of stretching of the center of the image as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.
- `size`: A <doc://com.apple.documentation/documentation/CoreFoundation/CGPoint> representing the desired size of the output image.
- `cropAmount`: A `float` representing the amount of cropping you apply to achieve the target size as an <doc://com.apple.documentation/documentation/Foundation/NSNumber>.

The following code creates a filter that results in a smaller image that’s distorted and cropped to be the defined size:

```swift
func stretchCrop(inputImage: CIImage) -> CIImage {
    let filter = CIFilter.stretchCrop()
    filter.inputImage = inputImage
    filter.cropAmount = 0.25
    filter.centerStretchAmount = 0.25
    filter.size = CGPoint(
        x: inputImage.extent.width * 2,
        y: inputImage.extent.size.height * 0.8
    )
    return filter.outputImage!
}
```

![Two images arranged horizontally. The left image contains a photograph of the Golden Gate Bridge with a clear sky in the background. The right image shows the result of applying the stretch crop filter. The image has been stretched in the horizontal direction and cropped in the vertical direction.](images/com.apple.coreimage/media-4407279@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)