<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ImageIO",
  "identifier" : "/documentation/ImageIO/CGImageDestinationCreateWithData(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Image I/O"
    ],
    "preciseIdentifier" : "c:@F@CGImageDestinationCreateWithData"
  },
  "title" : "CGImageDestinationCreateWithData(_:_:_:_:)"
}
-->

# CGImageDestinationCreateWithData(_:_:_:_:)

Creates an image destination that writes to a Core Foundation mutable data object.

```
func CGImageDestinationCreateWithData(_ data: CFMutableData, _ type: CFString, _ count: Int, _ options: CFDictionary?) -> CGImageDestination?
```

## Parameters

`data`

The data object in which to store the image data.

`type`

The uniform type identifier of the resulting image file. For a list of system-declared and third-party identifiers, see <doc://com.apple.documentation/documentation/UniformTypeIdentifiers>.

`count`

The number of images (not including thumbnail images) you want to include in the image file.

`options`

Future options. Specify `NULL` for this parameter.

## Return Value

An image destination, or `NULL` if an error occurs. You are responsible for releasing this object using <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease>.

## Discussion

---

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)