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, you must choose a CameraFormat that supports a RAW container format like 'dng' via supportedPhotoContainerFormats:
const device = ...
const format = useCameraFormat(device, [
{ photoContainerFormat: 'dng' }
])const device = ...
const format = getCameraFormat(device, [
{ photoContainerFormat: 'dng' }
])Then, configure your CameraPhotoOutput to capture in RAW/DNG photos:
const format = ...
const hasDNG = format.supportedPhotoContainerFormats.includes('dng')
const photoOutput = usePhotoOutput({
containerFormat: hasDNG ? 'dng' : 'native'
})const device = ...
const hasDNG = format.supportedPhotoContainerFormats.includes('dng')
const photoOutput = HybridCameraFactory.createPhotoOutput({
containerFormat: hasDNG ? 'dng' : 'native'
})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.