Capturing RAW Photos
Capturing RAW Photos using Adobe DNG containers
A typical Photo pipeline consists of multiple processing stages in the ISP - white balancing, color interpolation and correction, colorspace conversions, and finally JPEG/HEIF compression.
Many modern phones support skipping the processing stages entirely, allowing applications to capture true RAW photos.
RAW photos are typically captured in DNG format (see the 'dng' PhotoContainerFormat).
Prepare the pipeline for RAW
To capture RAW, configure your CameraPhotoOutput to capture in RAW/DNG photos by setting the containerFormat to 'dng':
const photoOutput = usePhotoOutput({
containerFormat: 'dng'
})const photoOutput = VisionCamera.createPhotoOutput({
containerFormat: 'dng'
})The CameraSession internally negotiates your Constraints and outputs to find a configuration that supports RAW capture. If RAW is not available on the device, the session configuration will fail - you can check support upfront via isSessionConfigSupported(...).
Use a Preview Image
Since RAW capture uses much higher bandwidth, it is also slower to capture a single Photo.
To provide instant user-feedback, it is recommended to request a Preview Image to display as a thumbnail - see "Photo Output Callbacks: Preview Image" for more information.
Capture RAW
Then, capture a RAW photo using capturePhoto(...):
const photoOutput = ...
const photo = await photoOutput.capturePhoto(
{ /* options */ },
{ /* callbacks */ }
)The captured Photo's RAW pixel data can be accessed via getPixelBuffer():
const photo = ...
if (photo.hasPixelBuffer) {
const buffer = photo.getPixelBuffer()
}When a RAW photo is saved via saveToTemporaryFileAsync() it is saved to a .dng file.
Apple ProRAW
If available, Apple devices may automatically capture in Apple ProRAW instead of regular DNG RAW. This provides better multi-Frame fuse details and supports quality prioritization.