Photo

interface Photo : AutoCloseable

A photo captured in memory by CameraPhotoOutput.capturePhoto.

Save it with saveToFile or saveToTemporaryFile, or read its encoded bytes with getFileData (e.g. to decode it into an image to display). Convert it to a displayable Image with toImage, or use the platform-specific conversions: Photo.toBitmap() on Android and Photo.toUIImage() on iOS.

A Photo holds native memory: dispose it as soon as it is no longer needed. It implements AutoCloseable, so use { } disposes it automatically.

Properties

Link copied to clipboard

The CameraCalibrationData captured with this photo, if CapturePhotoSettings.enableCameraCalibrationDataDelivery was enabled and the device supports it. iOS only.

Link copied to clipboard
Link copied to clipboard
abstract val depth: Depth?

The Depth data captured with this photo, if CapturePhotoSettings.enableDepthData was enabled and the device supports it. It is disposed together with this photo.

Link copied to clipboard
abstract val hasPixelBuffer: Boolean

Whether this photo has a native pixel buffer, readable with getPixelBuffer.

Link copied to clipboard
abstract val height: Int

The height of this photo, in pixels.

Link copied to clipboard
abstract val isMirrored: Boolean

Whether this photo is mirrored along its vertical axis.

Link copied to clipboard
abstract val isRawPhoto: Boolean

Whether this photo is a RAW photo (no processing applied), or a processed one (e.g. JPEG).

Link copied to clipboard

The CameraOrientation this photo was captured in, applied lazily via EXIF or when converting it.

Link copied to clipboard
abstract val timestamp: Double

The time this photo was captured at, using the system's host clock, in seconds.

Link copied to clipboard
abstract val width: Int

The width of this photo, in pixels.

Functions

Link copied to clipboard
open override fun close()

Same as dispose.

Link copied to clipboard
abstract fun dispose()

Releases the native memory of this photo. It can no longer be used afterwards.

Link copied to clipboard
abstract suspend fun getFileData(): ByteArray

Gets the encoded file data of this photo, after processing and including EXIF metadata.

Link copied to clipboard
abstract fun getPixelBuffer(): ByteArray

Gets a copy of this photo's pixels, without EXIF data.

Link copied to clipboard
abstract suspend fun saveToFile(path: String)

Saves this photo in its containerFormat to the given path, a full filesystem path including the file name and extension. The parent directories must exist, and the file must not.

Link copied to clipboard
abstract suspend fun saveToTemporaryFile(): String

Saves this photo in its containerFormat to a temporary file, and returns its filesystem path.

Link copied to clipboard

Converts this Photo to an Android Bitmap, with its Photo.orientation and mirroring applied.

Link copied to clipboard
abstract fun toImage(): Image

Converts this photo to a decoded Image, with its orientation and mirroring applied. This runs synchronously, on the calling thread.

Link copied to clipboard
open suspend fun toImageAsync(): Image

Same as toImage, but runs on a background dispatcher.

Link copied to clipboard
fun Photo.toUIImage(): UIImage

Converts this Photo to a UIImage, applying its Photo.orientation and Photo.isMirrored through the image's imageOrientation. Same as Photo.toImage followed by Image.toUIImage().