<!--
{
  "availability" : [
    "iOS: 10.0.0 - 11.0.0",
    "iPadOS: 10.0.0 - 11.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCapturePhotoOutput/jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCapturePhotoOutput(cm)JPEGPhotoDataRepresentationForJPEGSampleBuffer:previewPhotoSampleBuffer:"
  },
  "title" : "jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)"
}
-->

# jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)

Returns data in JPEG format corresponding to the captured photo in the specified sample buffer.

```
class func jpegPhotoDataRepresentation(forJPEGSampleBuffer JPEGSampleBuffer: CMSampleBuffer, previewPhotoSampleBuffer: CMSampleBuffer?) -> Data?
```

## Parameters

`JPEGSampleBuffer`

A sample buffer containing the JPEG 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 JPEG output as a thumbnail image. Pass `nil` to skip adding a preview image to the output.

## Return Value

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

## Discussion

After you request a photo capture with the [`capturePhoto(with:delegate:)`](/documentation/AVFoundation/AVCapturePhotoOutput/capturePhoto(with:delegate:)) method, the photo capture output delivers results to your delegate as one or more <doc://com.apple.documentation/documentation/CoreMedia/CMSampleBuffer> objects. (See the [`photoOutput(_:didFinishProcessingPhoto:previewPhoto:resolvedSettings:bracketSettings:error:)`](/documentation/AVFoundation/AVCapturePhotoCaptureDelegate/photoOutput(_:didFinishProcessingPhoto:previewPhoto:resolvedSettings:bracketSettings:error:)) method.) To repackage the sample buffer’s content for output as a JPEG file, use this class method. Optionally, you can include metadata in the resulting JPEG output by attaching it to the sample buffer before calling this method.

> Important:
> The `jpegSampleBuffer` parameter must reference a sample buffer from a JPEG capture. See the ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCapturePhotoSettings/format`` property for photo capture settings.

---

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)