<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/crop(at:destination:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVA2A06StaticC6FormatRzrlE4crop2at11destinationySo7CGPointV_AEy_xGtF"
  },
  "title" : "crop(at:destination:)"
}
-->

# crop(at:destination:)

Crops the pixel buffer to a rectangle that’s defined by an origin and the destination buffer’s dimensions.

```
func crop(at origin: CGPoint, destination: vImage.PixelBuffer<Format>)
```

## Parameters

`origin`

A point that specifies the origin of the image to keep.

`destination`

The destination pixel buffer.

## Discussion

For example, the following code populates a pixel buffer from the center 3 x 3 pixels of a 5 x 5 planar buffer:

```swift
let src = vImage.PixelBuffer<vImage.Planar8>(
    pixelValues: [ 10, 11, 12, 13, 14,
                   20, 21, 22, 23, 24,
                   30, 31, 32, 33, 34,
                   40, 41, 42, 43, 44,
                   50, 51, 52, 53, 54 ],
    size: vImage.Size(width: 5,
                      height: 5))

let dest = vImage.PixelBuffer<vImage.Planar8>(
    size: vImage.Size(width: 3,
                      height: 3))

src.crop(at: CGPoint(x: 1, y: 1),
         destination: dest)

// Prints:
//  [ 21, 22, 23,
//    31, 32, 33,
//    41, 42, 43 ]
print(dest.array)
```

---

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)