Enable delivery of reduced-size images with the main image in a photo capture.
Generating your own preview or thumbnail images from high-resolution source images can be difficult and time-consuming. Instead, use
AVCapture to get easy, fast preview and thumbnail generation as part of your capture process.
In the capture system, the names preview and thumbnail have specific meanings:
A preview image is a reduced-size (screen resolution or smaller) version of the photo, in an uncompressed format, delivered only in memory for purposes of displaying feedback shortly after capture. For example, the system Camera app displays a preview image of the last captured photo.
A thumbnail image is a smaller version of the photo, encoded in a compressed format and embedded in the output image file for use by other software. For example, image browsers reading a folder full of images can preview the contents of many files without reading and decoding each file's entire contents.
To request that a thumbnail version of the photo be embedded in the resulting image file, use the photo settings object's
embedded dictionary to specify the format and size of the thumbnail.
When the photo output calls your delegate's
photo method, you can get the preview image from the
preview property. A pixel buffer provides direct access to pixel data, so you can process or display it using other graphics technologies such as Metal, Vision, or Core Image. One way to simply display the preview image in your UI is to use Core Image to wrap the buffer in a UIImage object:
If you requested an embedded thumbnail image, that image isn't directly accessible from the
AVCapture object—it's embedded in the image file data that you get by calling the photo object's