<!--
{
  "availability" : [
    "iOS: 4.0.0 - 10.0.0",
    "iPadOS: 4.0.0 - 10.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.7.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureStillImageOutput/jpegStillImageNSDataRepresentation(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureStillImageOutput(cm)jpegStillImageNSDataRepresentation:"
  },
  "title" : "jpegStillImageNSDataRepresentation(_:)"
}
-->

# jpegStillImageNSDataRepresentation(_:)

Returns an `NSData` representation of a still image data and metadata attachments in a JPEG sample buffer.

```
class func jpegStillImageNSDataRepresentation(_ jpegSampleBuffer: CMSampleBuffer) -> Data?
```

## Parameters

`jpegSampleBuffer`

The sample buffer carrying JPEG image data, optionally with `Exif` metadata sample buffer attachments.

    This method throws an     <doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException>     if     `jpegSampleBuffer`     is     `NULL`     or not in the JPEG format.

## Return Value

An `NSData` representation of `jpegSampleBuffer`.

## Discussion

This method merges the image data and `Exif` metadata sample buffer attachments without recompressing the image.

The returned `NSData` object is suitable for writing to disk.

---

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)