<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIImage/clamped(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image"
    ],
    "preciseIdentifier" : "c:objc(cs)CIImage(im)imageByClampingToRect:"
  },
  "title" : "clamped(to:)"
}
-->

# clamped(to:)

Returns a new image created by cropping to a specified area, then making the pixel colors along the edges of the cropped image extend infinitely in all directions.

```
func clamped(to rect: CGRect) -> CIImage
```

## Parameters

`rect`

The rectangle, in image coordinates, to which to crop the image.

## Return Value

An image object representing the result of the clamp operation.

## Discussion

Calling this method is equivalent to cropping the image (with the [`cropped(to:)`](/documentation/CoreImage/CIImage/cropped(to:)) method or the [CICrop](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CICrop) filter), then using the [`clampedToExtent()`](/documentation/CoreImage/CIImage/clampedToExtent()) method (or the [CIAffineClamp](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIAffineClamp) filter), which creates an image of infinite extent by repeating pixel colors from the edges of the cropped image.

---

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)