---
title: CGImageDestination
framework: imageio
role: symbol
role_heading: Class
path: imageio/cgimagedestination
---

# CGImageDestination

An opaque type that you use to write image data to a URL, data object, or data consumer.

## Declaration

```swift
class CGImageDestination
```

## Overview

Overview A CGImageDestination object provides an abstract interface for saving image data. Use an image destination to represent a single image, or multiple images packaged together. For example, you might create an image that also contains a thumbnail. You can also use the image destination to add metadata to your images. An image destination outputs data to a URL, a CFData object, or a CGDataConsumer object, which you specify at creation time. After you create the image destination, add the image data and properties. When you are done, call CGImageDestinationFinalize(_:) to finalize the image data and write it to the output location. For more information, see Image I/O Programming Guide.

## Topics

### Creating an Image Destination

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

### Adding Images to the Destination

- [CGImageDestinationAddImage(_:_:_:)](imageio/cgimagedestinationaddimage(_:_:_:).md)
- [CGImageDestinationAddImageFromSource(_:_:_:_:)](imageio/cgimagedestinationaddimagefromsource(_:_:_:_:).md)

### Adding Metadata to the Image

- [CGImageDestinationSetProperties(_:_:)](imageio/cgimagedestinationsetproperties(_:_:).md)
- [CGImageDestinationAddAuxiliaryDataInfo(_:_:_:)](imageio/cgimagedestinationaddauxiliarydatainfo(_:_:_:).md)

### Finalizing the Image Data

- [CGImageDestinationFinalize(_:)](imageio/cgimagedestinationfinalize(_:).md)

### Getting the Image Types

- [CGImageDestinationCopyTypeIdentifiers()](imageio/cgimagedestinationcopytypeidentifiers().md)
- [CGImageDestinationGetTypeID()](imageio/cgimagedestinationgettypeid().md)

### Configuring the Image Behaviors

- [kCGImageDestinationLossyCompressionQuality](imageio/kcgimagedestinationlossycompressionquality.md)
- [kCGImageDestinationBackgroundColor](imageio/kcgimagedestinationbackgroundcolor.md)
- [kCGImageDestinationDateTime](imageio/kcgimagedestinationdatetime.md)
- [kCGImageDestinationEmbedThumbnail](imageio/kcgimagedestinationembedthumbnail.md)
- [kCGImageDestinationImageMaxPixelSize](imageio/kcgimagedestinationimagemaxpixelsize.md)
- [kCGImageDestinationMetadata](imageio/kcgimagedestinationmetadata.md)
- [kCGImageDestinationMergeMetadata](imageio/kcgimagedestinationmergemetadata.md)
- [kCGImageDestinationOptimizeColorForSharing](imageio/kcgimagedestinationoptimizecolorforsharing.md)
- [kCGImageDestinationOrientation](imageio/kcgimagedestinationorientation.md)
- [kCGImageDestinationPreserveGainMap](imageio/kcgimagedestinationpreservegainmap.md)
- [kCGImageMetadataShouldExcludeGPS](imageio/kcgimagemetadatashouldexcludegps.md)
- [kCGImageMetadataShouldExcludeXMP](imageio/kcgimagemetadatashouldexcludexmp.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Image Management

- [CGImageSource](imageio/cgimagesource.md)
