<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/createCGImage(_:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)createCGImage:fromRect:"
  },
  "title" : "createCGImage(_:from:)"
}
-->

# createCGImage(_:from:)

Creates a Core Graphics image from a region of a Core Image image instance.

```
func createCGImage(_ image: CIImage, from fromRect: CGRect) -> CGImage?
```

## Parameters

`image`

A [`CIImage`](/documentation/CoreImage/CIImage) image instance for which to create a `CGImage`.

`fromRect`

The `CGRect` region of the `image` to use.
This region relative to the cartesean coordinate system of `image`.
This region will be intersected with integralized and intersected with `image.extent`.

## Return Value


Returns a new `CGImage` instance.
You are responsible for releasing the returned image when you no longer need it.
The returned value will be `null` if the extent is empty or too big.

## Discussion

The color space of the created `CGImage` will be sRGB unless the receiving [`CIContext`](/documentation/CoreImage/CIContext)
was created with a `kCIContextOutputColorSpace` option.

Normally the pixel format of the created CGImage will be 8 bits-per-component.
It will be 16 bits-per-component float if the above color space is HDR.

---

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)