<!--
{
  "documentType" : "article",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/capturing-a-bracketed-photo-sequence",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Capturing a bracketed photo sequence"
}
-->

# Capturing a bracketed photo sequence

Capture several photos at once, varying parameters like exposure duration or light sensitivity.

## Discussion

Bracketing is a well-known photographic technique in which a sequence of shots is rapidly taken of the same scene, usually varying only in a single parameter such as aperture or shutter speed (exposure length). Experienced photographers use this technique to help them choose the best photos after shooting, or to apply offline post-processing that fuses multiple images together to create extended dynamic range or other special effects.

In iOS, you can use [`AVCapturePhotoOutput`](/documentation/AVFoundation/AVCapturePhotoOutput) and [`AVCapturePhotoBracketSettings`](/documentation/AVFoundation/AVCapturePhotoBracketSettings) to automatically capture a bracket of photos for each [`capturePhoto(with:delegate:)`](/documentation/AVFoundation/AVCapturePhotoOutput/capturePhoto(with:delegate:)) call. Once you’ve built a single-exposure camera in your app (see [Capturing still and Live Photos](/documentation/AVFoundation/capturing-still-and-live-photos)), follow these steps to add multi-image bracket support.

### Choose bracket settings

You specify a multi-exposure bracket by providing an array of bracket settings obejcts. iOS offers two types of automatic bracketing:

- Use [`AVCaptureAutoExposureBracketedStillImageSettings`](/documentation/AVFoundation/AVCaptureAutoExposureBracketedStillImageSettings) to create a bracket that varies exposure-compensation values relative to automatic exposure.
- Use [`AVCaptureManualExposureBracketedStillImageSettings`](/documentation/AVFoundation/AVCaptureManualExposureBracketedStillImageSettings) to create a bracket with custom exposure durations and ISO sensitivity values for each photo in the bracket.

To define a bracket, create an array of one of these types, with values that describe the settings variations you want to capture. For example, the code below defines a bracket that captures three images at three different exposure values.

```swift
// Get AVCaptureBracketedStillImageSettings for a set of exposure values.
let exposureValues: [Float] = [-2, 0, +2]
let makeAutoExposureSettings = AVCaptureAutoExposureBracketedStillImageSettings.autoExposureSettings(exposureTargetBias:)
let exposureSettings = exposureValues.map(makeAutoExposureSettings)
```

> Tip:
> In Swift, you can easily convert an array of exposure values to an array of bracket settings by passing the appropriate initializer to the `map(_:)` function, as shown above.

### Create photo settings and shoot

Instead of the [`AVCapturePhotoSettings`](/documentation/AVFoundation/AVCapturePhotoSettings) object you create when shooting a single photo, to shoot a bracketed capture you’ll need an [`AVCapturePhotoBracketSettings`](/documentation/AVFoundation/AVCapturePhotoBracketSettings) object. This object combines the general settings that apply to all photos in the bracket with your bracket settings that specify how each photo differs from the rest of the bracket.

As with single-image capture, you create a photo settings object by choosing the image codec and file format for the resulting photos, but you also provide the bracket settings you’ve chosen.

```swift
// Create photo settings for HEIF/HEVC capture and no RAW output
// and enable cross-bracket image stabilization.
let photoSettings = AVCapturePhotoBracketSettings(rawPixelFormatType: 0,
    processedFormat: [AVVideoCodecKey : AVVideoCodecType.hevc],
    bracketedSettings: exposureSettings)
photoSettings.isLensStabilizationEnabled =
    self.photoOutput.isLensStabilizationDuringBracketedCaptureSupported

// Shoot the bracket, using a custom class to handle capture delegate callbacks.
let captureProcessor = PhotoCaptureProcessor()
self.photoOutput.capturePhoto(with: photoSettings, delegate: captureProcessor)
```

> Tip:
> Turning on ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCapturePhotoBracketSettings/isLensStabilizationEnabled`` (if supported) causes the camera to apply optical image stabilization (OIS) across the entire bracket, so that photos resulting from the bracket still line up with each other even if the device moves during capture.

### Handle bracketed capture results

The photo output calls your delegate’s [`photoOutput(_:didFinishProcessingPhoto:error:)`](/documentation/AVFoundation/AVCapturePhotoCaptureDelegate/photoOutput(_:didFinishProcessingPhoto:error:)) method at least once for each exposure in the bracket, and possibly additional times depending on your capture settings. For example, if you request RAW+HEIF capture in a three-exposure bracket, the photo output calls your delegate’s `didFinishProcessingPhoto` method six times (2 formats × 3 exposures), providing six [`AVCapturePhoto`](/documentation/AVFoundation/AVCapturePhoto) objects.

To keep track of multiple results, compare the [`photoCount`](/documentation/AVFoundation/AVCapturePhoto/photoCount) from each photo to the [`expectedPhotoCount`](/documentation/AVFoundation/AVCaptureResolvedPhotoSettings/expectedPhotoCount) of your resolved settings. When those numbers are equal, you’ve received all results from the capture.

---

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)