---
title: "CGImageDestinationCreateWithData(_:_:_:_:)"
framework: imageio
role: symbol
role_heading: Function
path: "imageio/cgimagedestinationcreatewithdata(_:_:_:_:)"
---

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

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

## Declaration

```swift
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

Return Value An image destination, or NULL if an error occurs. You are responsible for releasing this object using CFRelease.

## See Also

### Creating an Image Destination

- [CGImageDestinationCreateWithURL(_:_:_:_:)](imageio/cgimagedestinationcreatewithurl(_:_:_:_:).md)
- [CGImageDestinationCreateWithDataConsumer(_:_:_:_:)](imageio/cgimagedestinationcreatewithdataconsumer(_:_:_:_:).md)
