---
title: "init(fromDictionaryRepresentation:)"
framework: avfoundation
role: symbol
role_heading: Initializer
path: "avfoundation/avdepthdata/init(fromdictionaryrepresentation:)"
---

# init(fromDictionaryRepresentation:)

Creates a depth data object from depth information such as that found in an image file.

## Declaration

```swift
convenience init(fromDictionaryRepresentation imageSourceAuxDataInfoDictionary: [AnyHashable : Any]) throws
```

## Parameters

- `imageSourceAuxDataInfoDictionary`: A dictionary of primitive depth-related information, in the format provided by the doc://com.apple.documentation/documentation/ImageIO/CGImageSourceCopyAuxiliaryDataInfoAtIndex(_:_:_:) function.

## Mentioned in

Creating auxiliary depth data manually

## Discussion

Discussion When using CGImageSource functions to read from a HEIF, JPEG, or DNG file containing depth data (as well as image data), you can use the  CGImageSourceCopyAuxiliaryDataInfoAtIndex(_:_:_:) function to load primitive depth map information, then use this initializer to create an AVDepthData object, as shown below. - (nullable AVDepthData *)depthDataFromImageData:(nonnull NSData *)imageData { 	AVDepthData *depthData = nil;

CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imageData, NULL); 	if (imageSource) { 		NSDictionary *auxDataDictionary = (__bridge NSDictionary *)CGImageSourceCopyAuxiliaryDataInfoAtIndex(imageSource, 0, kCGImageAuxiliaryDataTypeDisparity); 		if (auxDataDictionary) { 			depthData = [AVDepthData depthDataFromDictionaryRepresentation:auxDataDictionary error:NULL]; 		}

CFRelease(imageSource); 	}

return depthData; }

## See Also

### Creating depth data

- [dictionaryRepresentation(forAuxiliaryDataType:)](avfoundation/avdepthdata/dictionaryrepresentation(forauxiliarydatatype:).md)
