---
title: "CVImageBufferCreateColorSpaceFromAttachments(_:)"
framework: corevideo
role: symbol
role_heading: Function
path: "corevideo/cvimagebuffercreatecolorspacefromattachments(_:)"
---

# CVImageBufferCreateColorSpaceFromAttachments(_:)

Attempts to create a Core Graphics color space from the image buffer’s attachments that you specify.

## Declaration

```swift
func CVImageBufferCreateColorSpaceFromAttachments(_ attachments: CFDictionary) -> Unmanaged<CGColorSpace>?
```

## Parameters

- `attachments`: The dictionary of attachments for an image buffer, which you can obtain by calling doc://com.apple.corevideo/documentation/CoreVideo/CVBufferCopyAttachments(_:_:) on the image buffer.

## Return Value

Return Value A CGColorSpace object that represents the color space of the image buffer, or nil if the dictionary doesn’t contain the information required to create a CGColorSpace instance.

## Discussion

Discussion To generate a CGColorSpace instance, the attachments dictionary needs to include values for either: kCVImageBufferICCProfileKey kCVImageBufferColorPrimariesKey, kCVImageBufferTransferFunctionKey, kCVImageBufferYCbCrMatrixKey, and possibly kCVImageBufferGammaLevelKey Use CGColorSpaceRelease to release the color space when you’re done with it.
