---
title: cgImageRepresentation()
framework: avfoundation
role: symbol
role_heading: Instance Method
path: avfoundation/avcapturephoto/cgimagerepresentation()
---

# cgImageRepresentation()

Extracts and returns the captured photo’s primary image as a Core Graphics image object.

## Declaration

```swift
func cgImageRepresentation() -> CGImage?
```

## Return Value

Return Value A Core Graphics image representation of the captured photo, or nil if the image cannot be converted.

## See Also

### Packaging data for file output

- [fileDataRepresentation(with:)](avfoundation/avcapturephoto/filedatarepresentation(with:).md)
- [AVCapturePhotoFileDataRepresentationCustomizer](avfoundation/avcapturephotofiledatarepresentationcustomizer.md)
- [fileDataRepresentation()](avfoundation/avcapturephoto/filedatarepresentation().md)
- [previewCGImageRepresentation()](avfoundation/avcapturephoto/previewcgimagerepresentation().md)
- [fileDataRepresentation(withReplacementMetadata:replacementEmbeddedThumbnailPhotoFormat:replacementEmbeddedThumbnailPixelBuffer:replacementDepthData:)](avfoundation/avcapturephoto/filedatarepresentation(withreplacementmetadata:replacementembeddedthumbnailphotoformat:replacementembeddedthumbnailpixelbuffer:replacementdepthdata:).md)
