AVCapturePhotoOutput jpegPhotoDataRepresentation access preview photo

900 Views Asked by At

I see that iOS 10 introduces AVCapturePhotoOutput as the new class to deal with capturing photo's and has the ability to create a preview/thumbnail image alongside the main image by passing two buffers to the AVCapturePhotoCaptureDelegate method capture.

This can then be represented as JPEG data through jpegPhotoDataRepresentation, however I'm intrigued and unable to find out how the preview image is stored then accessed. I'm guessing a UIImageView would automatically select either image dependant upon view bounds? How would you go about manually selecting either image?

let imageData = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: photoSampleBuffer, previewPhotoSampleBuffer: previewPhotoSampleBuffer)
captureImageView.image = UIImage(data: imageData)
1

There are 1 best solutions below

0
On

Yes, the thumbnail is embedded in the header for the full size JPEG image. For more information, you can check out: https://en.m.wikipedia.org/wiki/JPEG_File_Interchange_Format