---
title: cgImage
framework: coreimage
role: symbol
role_heading: Instance Property
path: coreimage/ciimage/cgimage
---

# cgImage

The CoreGraphics image object this image was created from, if applicable.

## Declaration

```swift
var cgImage: CGImage? { get }
```

## Discussion

Discussion If this image was created using the init(cgImage:) or init(contentsOf:) initializer, this property’s value is the CGImage object that provides the image’s underlying image data. Otherwise, this property’s value is nil—in this case you can obtain a CoreGraphics image by rendering the image with the CIContext createCGImage(_:from:) method.

## See Also

### Accessing Original Image Content

- [pixelBuffer](coreimage/ciimage/pixelbuffer.md)
- [depthData](coreimage/ciimage/depthdata.md)
- [portraitEffectsMatte](coreimage/ciimage/portraiteffectsmatte.md)
- [semanticSegmentationMatte](coreimage/ciimage/semanticsegmentationmatte.md)
