---
title: "dngPhotoDataRepresentation(forRawSampleBuffer:previewPhotoSampleBuffer:)"
framework: avfoundation
role: symbol
role_heading: Type Method
path: "avfoundation/avcapturephotooutput/dngphotodatarepresentation(forrawsamplebuffer:previewphotosamplebuffer:)"
---

# dngPhotoDataRepresentation(forRawSampleBuffer:previewPhotoSampleBuffer:)

Returns data in digital negative (DNG) format corresponding to the captured RAW photo in the specified sample buffer.

## Declaration

```swift
class func dngPhotoDataRepresentation(forRawSampleBuffer rawSampleBuffer: CMSampleBuffer, previewPhotoSampleBuffer: CMSampleBuffer?) -> Data?
```

## Parameters

- `rawSampleBuffer`: A sample buffer containing the RAW photo capture result to be formatted for output.
- `previewPhotoSampleBuffer`: An optional additional sample buffer containing a preview-resolution version of the photo capture result, to be added to the DNG output as a thumbnail image. Pass nil to skip adding a preview image to the output.

## Return Value

Return Value A data object containing a DNG representation of the requested photo capture results, or nil if the sample buffers cannot be packaged for output.

## Discussion

Discussion After you request a photo capture with the capturePhoto(with:delegate:) method, the photo capture output delivers results to your delegate as one or more CMSampleBuffer objects. (See the photoOutput(_:didFinishProcessingRawPhoto:previewPhoto:resolvedSettings:bracketSettings:error:) method.) To repackage the sample buffer’s content for output as a DNG file, use this class method. Optionally, you can include metadata in the resulting DNG output by attaching it to the sample buffer before calling this method. important: The rawSampleBuffer parameter must reference a sample buffer from a RAW capture. See the rawPhotoPixelFormatType property for photo capture settings.

## See Also

### Getting formatted output

- [jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)](avfoundation/avcapturephotooutput/jpegphotodatarepresentation(forjpegsamplebuffer:previewphotosamplebuffer:).md)
