# ImageCapture

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/ImageCapture.java+class:androidx.camera.core.ImageCapture) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***


```
class ImageCapture : UseCase
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.camera.core.UseCase](https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase) ||
|   | ↳ | [androidx.camera.core.ImageCapture](https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture) |

*** ** * ** ***

A use case for taking a picture.

This class is designed for basic picture taking. It provides takePicture() functions to take a picture to memory or save to a file, and provides image metadata. Pictures are taken in automatic mode after focus has converged. The flash mode can additionally be set by the application.

TakePicture returns immediately and a listener is called to provide the results after the capture completes. Multiple calls to takePicture will take pictures sequentially starting after the previous picture is captured.

Note that focus and exposure metering regions can be controlled via `https://developer.android.com/reference/kotlin/androidx/camera/core/Preview`.

When capturing to memory, the captured image is made available through an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` via an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback`.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder : https://developer.android.com/reference/kotlin/androidx/camera/core/ExtendableBuilder` Builder for an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `class https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Metadata` Holder class for metadata that will be saved with captured images. |
| `abstract class https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback` Callback for image capture events. |
| `interface https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback` Listener containing callbacks for image file I/O events. |
| `class https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions` Options for saving newly captured image. |
| `class https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions.Builder` Builder class for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions`. |
| `class https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileResults` Info about the saved image file. |
| `interface https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` Interface to do the application changes required for screen flash operations. |
| `interface https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlashListener` Callback listener for discovering when the application has completed its changes for a screen flash image capture. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_MAXIMIZE_QUALITY() = 0` Optimizes capture pipeline to prioritize image quality over latency. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_MINIMIZE_LATENCY() = 1` Optimizes capture pipeline to prioritize latency over image quality. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/camera/core/ExperimentalZeroShutterLag https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_ZERO_SHUTTER_LAG() = 2` Optimizes capture pipeline to have better latency while keeping good image quality. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#ERROR_CAMERA_CLOSED() = 3` An error indicating the request cannot be done due to camera is closed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#ERROR_CAPTURE_FAILED() = 2` An error reported by camera framework indicating the capture request is failed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#ERROR_FILE_IO() = 1` An error occurred while attempting to read or write a file, such as when saving an image to a File. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#ERROR_INVALID_CAMERA() = 4` An error indicating this ImageCapture is not bound to a valid camera. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#ERROR_UNKNOWN() = 0` An unknown error occurred. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_AUTO() = 0` Auto flash. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_OFF() = 2` No flash. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_ON() = 1` Always flash. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN() = 3` Screen flash. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_JPEG() = 0` Captures 8-bit standard dynamic range (SDR) images using the `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG` image format. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_JPEG_ULTRA_HDR() = 1` Captures Ultra HDR compressed images using the `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG_R` image format. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_RAW() = 2` Captures raw images in the `https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW_SENSOR` image format. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_RAW_JPEG() = 3` Captures raw images in the `https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW_SENSOR` and `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG` image formats. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getCaptureMode()()` Returns the set capture mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getFlashMode()()` Get the flash mode. |
| `java-static https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureCapabilities` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getImageCaptureCapabilities(androidx.camera.core.CameraInfo)(cameraInfo: https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo)` Returns `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureCapabilities` to query ImageCapture capability of the given `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1, to = 100) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getJpegQuality()()` Returns the JPEG quality setting. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getOutputFormat()()` Returns the output format setting. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector?` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getPostviewResolutionSelector()()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` used to select the postview size. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureLatencyEstimate` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getRealtimeCaptureLatencyEstimate()()` Returns an estimate of the capture and processing sequence duration based on the current camera configuration and scene conditions. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ResolutionInfo?` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getResolutionInfo()()` Gets selected resolution information of the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector?` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getResolutionSelector()()` Returns the resolution selector setting. |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash?` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getScreenFlash()()` Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` instance currently set, null if none. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#getTargetRotation()()` Returns the desired rotation of the output image. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#isPostviewEnabled()()` Returns if postview is enabled or not. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setCropAspectRatio(android.util.Rational)(aspectRatio: https://developer.android.com/reference/android/util/Rational.html)` Sets target cropping aspect ratio for output image. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setFlashMode(int)(flashMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the flash mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)(screenFlash: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash?)` Sets `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` for subsequent photo capture requests. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setTargetRotation(int)(rotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the desired rotation of the output image. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)( executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback )` Captures a new still image for in memory access. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)( outputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, imageSavedCallback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback )` Captures a new still image and saves to a file along with application specified metadata. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)( rawOutputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions, jpegOutputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, imageSavedCallback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback )` Captures two still images simultaneously and saves to a file along with application specified metadata. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#toString()()` |

| ### Extension functions |
|---|---|
| `suspend https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#(androidx.camera.core.ImageCapture).takePicture(kotlin.Function0,kotlin.Function1,kotlin.Function1)( onCaptureStarted: (() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, onCaptureProcessProgressed: ((https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, onPostviewBitmapAvailable: ((https://developer.android.com/reference/android/graphics/Bitmap.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? )` Captures a new still image for in memory access. |
| `suspend https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileResults` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#(androidx.camera.core.ImageCapture).takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,kotlin.Function0,kotlin.Function1,kotlin.Function1)( outputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions, onCaptureStarted: (() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, onCaptureProcessProgressed: ((https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)?, onPostviewBitmapAvailable: ((https://developer.android.com/reference/android/graphics/Bitmap.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? )` Captures a new still image and saves to a file along with application specified metadata. |

### Inherited functions

From [androidx.camera.core.UseCase](https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase) `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase#snapToSurfaceRotation(int)(orientation: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 359) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

A utility function that can convert the orientation degrees of `https://developer.android.com/reference/android/view/OrientationEventListener.html` to the nearest `https://developer.android.com/reference/android/view/Surface.html` rotation.

## Constants

### CAPTURE_MODE_MAXIMIZE_QUALITY

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val CAPTURE_MODE_MAXIMIZE_QUALITY = 0: Int
```

Optimizes capture pipeline to prioritize image quality over latency. When the capture mode is set to MAX_QUALITY, images may take longer to capture.

### CAPTURE_MODE_MINIMIZE_LATENCY

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val CAPTURE_MODE_MINIMIZE_LATENCY = 1: Int
```

Optimizes capture pipeline to prioritize latency over image quality. When the capture mode is set to MIN_LATENCY, images may capture faster but the image quality may be reduced.

### CAPTURE_MODE_ZERO_SHUTTER_LAG

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/camera#1.2.0)

```
@ExperimentalZeroShutterLag
const val CAPTURE_MODE_ZERO_SHUTTER_LAG = 2: Int
```

Optimizes capture pipeline to have better latency while keeping good image quality. When the capture mode is set to ZERO_SHUTTER_LAG, the latency between the shutter button is clicked and the picture is taken is expected to be minimized, compared with other capture modes.

ZERO_SHUTTER_LAG mode is aiming to provide the minimum latency for instant capture. It caches intermediate results and deliver the one with the closest timestamp when `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)` is invoked.

`https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#isZslSupported()` can be used to query the device capability to support this mode or not. However, this mode also depends on use cases configuration and flash mode settings. If VideoCapture is bound or flash mode is not OFF or OEM Extension is ON, this mode will be disabled automatically.

### ERROR_CAMERA_CLOSED

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val ERROR_CAMERA_CLOSED = 3: Int
```

An error indicating the request cannot be done due to camera is closed.

### ERROR_CAPTURE_FAILED

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val ERROR_CAPTURE_FAILED = 2: Int
```

An error reported by camera framework indicating the capture request is failed.

### ERROR_FILE_IO

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val ERROR_FILE_IO = 1: Int
```

An error occurred while attempting to read or write a file, such as when saving an image to a File.

### ERROR_INVALID_CAMERA

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val ERROR_INVALID_CAMERA = 4: Int
```

An error indicating this ImageCapture is not bound to a valid camera.

### ERROR_UNKNOWN

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val ERROR_UNKNOWN = 0: Int
```

An unknown error occurred.

See message parameter in onError callback or log for more details.

### FLASH_MODE_AUTO

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val FLASH_MODE_AUTO = 0: Int
```

Auto flash. The flash will be used according to the camera system's determination when taking a picture.

### FLASH_MODE_OFF

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val FLASH_MODE_OFF = 2: Int
```

No flash. The flash will never be used when taking a picture.

### FLASH_MODE_ON

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
const val FLASH_MODE_ON = 1: Int
```

Always flash. The flash will always be used when taking a picture.

### FLASH_MODE_SCREEN

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val FLASH_MODE_SCREEN = 3: Int
```

Screen flash. Display screen brightness will be used as alternative to flash when taking a picture with front camera.

This flash mode can be set via `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setFlashMode(int)` after setting a non-null `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` instance with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)`. This mode will always invoke all the necessary operations for a screen flash image capture, i.e. it is similar to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_ON()`, not `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_AUTO()`.

The following code snippet shows an example implementation of how this flash mode can be set to an `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` instance.

```kotlin
imageCapture.setScreenFlash(new ImageCapture.ScreenFlash() {
    
    public void apply(long expirationTimeMillis,
            ScreenFlashListener screenFlashListener) {
        whiteColorOverlayView.setVisibility(View.VISIBLE);
        maximizeScreenBrightness();
        screenFlashListener.onCompleted();
    }

    
    public void clear() {
        restoreScreenBrightness();
        whiteColorOverlayView.setVisibility(View.INVISIBLE);
    }
});

imageCapture.setFlashMode(ImageCapture.FLASH_MODE_SCREEN);
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setFlashMode(int)` |   |

### OUTPUT_FORMAT_JPEG

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val OUTPUT_FORMAT_JPEG = 0: Int
```

Captures 8-bit standard dynamic range (SDR) images using the `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG` image format.

### OUTPUT_FORMAT_JPEG_ULTRA_HDR

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
const val OUTPUT_FORMAT_JPEG_ULTRA_HDR = 1: Int
```

Captures Ultra HDR compressed images using the `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG_R` image format.

This format is backward compatible with SDR JPEG images and supports HDR rendering of content. This means that on older apps or devices, images appear seamlessly as regular JPEG; on apps and devices that have been updated to fully support the format, images appear as HDR.

For more information see [Support Ultra HDR](https://developer.android.com/media/grow/ultra-hdr).

### OUTPUT_FORMAT_RAW

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
const val OUTPUT_FORMAT_RAW = 2: Int
```

Captures raw images in the `https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW_SENSOR` image format.

### OUTPUT_FORMAT_RAW_JPEG

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
const val OUTPUT_FORMAT_RAW_JPEG = 3: Int
```

Captures raw images in the `https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW_SENSOR` and `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG` image formats.

## Public functions

### getCaptureMode

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun getCaptureMode(): Int
```

Returns the set capture mode.

This is set when constructing an ImageCapture using `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setCaptureMode(int)`. This is static for an instance of ImageCapture.

### getFlashMode

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun getFlashMode(): Int
```

Get the flash mode.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the flashMode. Value is `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_AUTO()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_ON()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()`, or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_OFF()`. |

### getImageCaptureCapabilities

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
java-static fun getImageCaptureCapabilities(cameraInfo: CameraInfo): ImageCaptureCapabilities
```

Returns `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureCapabilities` to query ImageCapture capability of the given `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo`.

Some capabilities are only exposed on Extensions-enabled cameras. To get the correct capabilities when Extensions are enabled, you need to pass the `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo` from the Extensions-enabled `https://developer.android.com/reference/kotlin/androidx/camera/core/Camera` instance. To do this, use an `https://developer.android.com/reference/kotlin/androidx/camera/extensions/ExtensionSessionConfig` containing the desired extension mode to invoke `https://developer.android.com/reference/kotlin/androidx/camera/lifecycle/ProcessCameraProvider#getCameraInfo(androidx.camera.core.CameraSelector,androidx.camera.core.SessionConfig)`.

The following code snippet demonstrates how to enable postview with an extension enabled:

```kotlin
ExtensionSessionConfig config = new ExtensionSessionConfig(ExtensionMode.NIGHT,
        extensionsManager);
CameraInfo extensionCameraInfo = cameraProvider.getCameraInfo(cameraSelector, config);
ImageCaptureCapabilities capabilities =
        ImageCapture.getImageCaptureCapabilities(extensionCameraInfo);
ImageCapture imageCapture = new ImageCapture.Builder()
        .setPostviewEnabled(capabilities.isPostviewSupported())
        .build();
```

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureCapabilities` | `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureCapabilities` |

### getJpegQuality

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun getJpegQuality(): @IntRange(from = 1, to = 100) Int
```

Returns the JPEG quality setting.

This is set when constructing an ImageCapture using `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setJpegQuality(int)`. If not set, a default value will be set according to the capture mode setting. JPEG compression quality 95 is set for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_MINIMIZE_LATENCY()` and 100 is set for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#CAPTURE_MODE_MAXIMIZE_QUALITY()`. This is static for an instance of ImageCapture.

### getOutputFormat

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getOutputFormat(): Int
```

Returns the output format setting.

If the output format was not provided to `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setOutputFormat(int)`, this will return the default of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_JPEG()`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the output format set for this `ImageCapture` use case. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setOutputFormat(int)` |   |

### getPostviewResolutionSelector

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getPostviewResolutionSelector(): ResolutionSelector?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/resolutionselector/ResolutionSelector` used to select the postview size.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setPostviewResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)` |   |

### getRealtimeCaptureLatencyEstimate

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getRealtimeCaptureLatencyEstimate(): ImageCaptureLatencyEstimate
```

Returns an estimate of the capture and processing sequence duration based on the current camera configuration and scene conditions. The value will vary as the scene and/or camera configuration change.

The processing estimate can vary based on device processing load.

If this method returns `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureLatencyEstimate#UNDEFINED_IMAGE_CAPTURE_LATENCY()`, it means that the camera HAL doesn't provide latency information. In this case, this method will consistently return `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCaptureLatencyEstimate#UNDEFINED_IMAGE_CAPTURE_LATENCY()` for the current camera configuration, as long as the UseCase and camera configuration remain unchanged (e.g., extensions mode and camera settings are kept the same).

### getResolutionInfo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

```
fun getResolutionInfo(): ResolutionInfo?
```

Gets selected resolution information of the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture`.

The returned `https://developer.android.com/reference/kotlin/androidx/camera/core/ResolutionInfo` will be expressed in the coordinates of the camera sensor. Note that the resolution might not be the same as the resolution of the received image by calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)` because the received image might have been rotated to the upright orientation using the target rotation setting by the device.

The resolution information might change if the use case is unbound and then rebound, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setTargetRotation(int)` is called to change the target rotation setting, or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setCropAspectRatio(android.util.Rational)` is called to change the crop aspect ratio setting. The application needs to call `getResolutionInfo()` again to get the latest `https://developer.android.com/reference/kotlin/androidx/camera/core/ResolutionInfo` for the changes.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ResolutionInfo?` | the resolution information if the use case has been bound by the `https://developer.android.com/reference/kotlin/androidx/camera/lifecycle/ProcessCameraProvider#bindToLifecycle(androidx.lifecycle.LifecycleOwner,androidx.camera.core.CameraSelector,androidx.camera.core.UseCase...)` API, or null if the use case is not bound yet. |

### getResolutionSelector

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

```
fun getResolutionSelector(): ResolutionSelector?
```

Returns the resolution selector setting.

This setting is set when constructing an ImageCapture using `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setResolutionSelector(androidx.camera.core.resolutionselector.ResolutionSelector)`.

### getScreenFlash

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun getScreenFlash(): ImageCapture.ScreenFlash?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` instance currently set, null if none.

### getTargetRotation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun getTargetRotation(): Int
```

Returns the desired rotation of the output image.

The rotation can be set prior to constructing an ImageCapture using `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setTargetRotation(int)` or dynamically by calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setTargetRotation(int)`. The rotation of an image taken is determined by the rotation value set at the time image capture is initiated, such as when calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)`.

If no target rotation is set by the application, it is set to the value of `https://developer.android.com/reference/android/view/Display.html#getRotation()` of the default display at the time the use case is created. The use case is fully created once it has been attached to a camera.

Value is one of the following:

- `Surface.ROTATION_0`
- `Surface.ROTATION_90`
- `Surface.ROTATION_180`
- `Surface.ROTATION_270`

<br />

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The rotation of the intended target. |

### isPostviewEnabled

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun isPostviewEnabled(): Boolean
```

Returns if postview is enabled or not.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setPostviewEnabled(boolean)` |   |

### setCropAspectRatio

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun setCropAspectRatio(aspectRatio: Rational): Unit
```

Sets target cropping aspect ratio for output image.

This aspect ratio is orientation-dependent. It should be expressed in the coordinate frame after rotating the image by the target rotation.

This sets the cropping rectangle returned by `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy#getCropRect()` returned from `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)`.

For example, assume the `aspectRatio` of 3x4. If an image has a resolution of 480x640 after applying the target rotation, then the output `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` of `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)` would have a cropping rectangle of 480x640 after applying the rotation degrees. However, if an image has a resolution of 640x480 after applying the target rotation, then the cropping rectangle of the output `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` would be 360x480 after applying the rotation degrees.

This crops the saved image when calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageSavedCallback)`. Note that the cropping will introduce an additional latency.

Cropping occurs around the center of the image and as though it were in the target rotation. For example, assume the `aspectRatio` of 3x4. If an image has a resolution of 480x640 after applying the target rotation, then the saved output image would be 480x640 after applying the EXIF orientation value. However, if an image has a resolution of 640x480 after applying the target rotation, then the saved output image would be 360x480 after applying the EXIF orientation value.

This setting value will be automatically updated to match the new target rotation value when `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setTargetRotation(int)` is called.

| Parameters |
|---|---|
| `aspectRatio: https://developer.android.com/reference/android/util/Rational.html` | New target aspect ratio. |

### setFlashMode

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun setFlashMode(flashMode: Int): Unit
```

Set the flash mode.

The flash control for the subsequent photo capture requests. Applications can check if there is a flash unit via `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraInfo#hasFlashUnit()` and update UI component if necessary. If there is no flash unit and `flashMode` is not `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()`, then calling this API will take no effect for the subsequent photo capture requests and they will act like `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_OFF()`.

When the torch is enabled via `https://developer.android.com/reference/kotlin/androidx/camera/core/CameraControl#enableTorch(boolean)`, the torch will remain enabled during photo capture regardless of flashMode setting. When the torch is disabled, flash will function as specified by `setFlashMode(int)`.

On some LEGACY devices like Samsung A3, taking pictures with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_AUTO()` mode could cause a crash. To workaround this CameraX will disable the auto flash behavior internally on devices that have this issue.

If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is set, a `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` implementation must be set via `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setScreenFlash(androidx.camera.core.ImageCapture.ScreenFlash)` before calling this API. Trying to use `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` without a `ScreenFlash` instance set or with a non-front camera will result in an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`. It is the application's responsibility to change flashMode while switching the camera in case it leads to a non-supported case (e.g. switching to rear camera while FLASH_MODE_SCREEN is still on).

| Parameters |
|---|---|
| `flashMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the flash mode. Value is `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_AUTO()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_ON()`, `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_OFF()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If flash mode is invalid or FLASH_MODE_SCREEN is used without a `ScreenFlash` instance or front camera. |

### setScreenFlash

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/camera#1.4.0)

```
fun setScreenFlash(screenFlash: ImageCapture.ScreenFlash?): Unit
```

Sets `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` for subsequent photo capture requests.

The calling of this API will take effect for `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` only and the `screenFlash` instance will be ignored for other flash modes.

If the implementation provided by the user is no longer valid (e.g. due to any `https://developer.android.com/reference/android/app/Activity.html` or `https://developer.android.com/reference/android/view/View.html` reference used in the implementation becoming invalid), user needs to re-set a new valid `ScreenFlash` or clear the previous one with `setScreenFlash(null)`, whichever appropriate.

| Parameters |
|---|---|
| `screenFlash: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash?` | A `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.ScreenFlash` implementation that is used to notify API users when app side changes need to be done. This will replace the previous `ScreenFlash` instance set with this method. |

### setTargetRotation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun setTargetRotation(rotation: Int): Unit
```

Sets the desired rotation of the output image.

This will affect the EXIF rotation metadata in images saved by takePicture calls and the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageInfo#getRotationDegrees()` value of the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy` returned by `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback`. These will be set to be the rotation, which if applied to the output image data, will make the image match target rotation specified here.

While rotation can also be set via `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setTargetRotation(int)`, using `setTargetRotation(int)` allows the target rotation to be set dynamically.

In general, it is best to use an `https://developer.android.com/reference/android/view/OrientationEventListener.html` to set the target rotation. This way, the rotation output will indicate which way is down for a given image. This is important since display orientation may be locked by device default, user setting, or app configuration, and some devices may not transition to a reverse-portrait display orientation. In these cases, set target rotation dynamically according to the `https://developer.android.com/reference/android/view/OrientationEventListener.html`, without re-creating the use case. `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase#snapToSurfaceRotation(int)` is a helper function to convert the orientation of the `https://developer.android.com/reference/android/view/OrientationEventListener.html` to a rotation value. See `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCase#snapToSurfaceRotation(int)` for more information and sample code.

When this function is called, value set by `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.Builder#setTargetResolution(android.util.Size)` will be updated automatically to make sure the suitable resolution can be selected when the use case is bound. Value set by `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setCropAspectRatio(android.util.Rational)` will also be updated automatically to make sure the output image is cropped into expected aspect ratio.

If no target rotation is set by the application, it is set to the value of `https://developer.android.com/reference/android/view/Display.html#getRotation()` of the default display at the time the use case is bound. To return to the default value, set the value to

```kotlin
context.getSystemService(WindowManager.class).getDefaultDisplay().getRotation();
```

takePicture uses the target rotation at the time it begins executing (which may be delayed waiting on a previous takePicture call to complete).

| Parameters |
|---|---|
| `rotation: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Target rotation of the output image, expressed as one of `https://developer.android.com/reference/android/view/Surface.html#ROTATION_0`, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_90`, `https://developer.android.com/reference/android/view/Surface.html#ROTATION_180`, or `https://developer.android.com/reference/android/view/Surface.html#ROTATION_270`. Value is one of the following: - `Surface.ROTATION_0` - `Surface.ROTATION_90` - `Surface.ROTATION_180` - `Surface.ROTATION_270` <br /> |

### takePicture

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun takePicture(
    executor: Executor,
    callback: ImageCapture.OnImageCapturedCallback
): Unit
```

Captures a new still image for in memory access.

The listener is responsible for calling `https://developer.android.com/reference/android/media/Image.html#close()` on the returned image.

For simultaneous image capture with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_RAW_JPEG()`, the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback#onCaptureSuccess(androidx.camera.core.ImageProxy)` will be triggered twice, one for `https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW_SENSOR` and the other for `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG`. The order of the callbacks for which image format is triggered first is not guaranteed.

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor in which the callback methods will be run. |
| `callback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback` | Callback to be invoked for the newly captured image. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is used without a non-null `ScreenFlash` instance set. |

### takePicture

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
fun takePicture(
    outputFileOptions: ImageCapture.OutputFileOptions,
    executor: Executor,
    imageSavedCallback: ImageCapture.OnImageSavedCallback
): Unit
```

Captures a new still image and saves to a file along with application specified metadata.

If the `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture` is in a `https://developer.android.com/reference/kotlin/androidx/camera/core/UseCaseGroup` where `https://developer.android.com/reference/kotlin/androidx/camera/core/ViewPort` is set, or `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#setCropAspectRatio(android.util.Rational)` is used, the image may be cropped before saving to disk which causes an additional latency.

| Parameters |
|---|---|
| `outputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions` | Options to store the newly captured image. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor in which the callback methods will be run. |
| `imageSavedCallback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback` | Callback to be called for the newly captured image. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is used without a a non-null `ScreenFlash` instance set. Also if `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_RAW_JPEG()` is used. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ViewPort` |   |

### takePicture

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera#1.5.0)

```
fun takePicture(
    rawOutputFileOptions: ImageCapture.OutputFileOptions,
    jpegOutputFileOptions: ImageCapture.OutputFileOptions,
    executor: Executor,
    imageSavedCallback: ImageCapture.OnImageSavedCallback
): Unit
```

Captures two still images simultaneously and saves to a file along with application specified metadata.

Currently only `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_RAW_JPEG()` is supporting simultaneous image capture. It needs two `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions`, the first one is used for `https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW_SENSOR` image and the second one is for `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG`. The order of the callbacks for which image format is triggered first is not guaranteed. Check with `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileResults#getImageFormat()` in `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback#onImageSaved(androidx.camera.core.ImageCapture.OutputFileResults)` for the image format.

| Parameters |
|---|---|
| `rawOutputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions` | Options to store the newly captured raw image. |
| `jpegOutputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions` | Options to store the newly captured jpeg image. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The executor in which the callback methods will be run. |
| `imageSavedCallback: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback` | Callback to be called for the newly captured image. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#FLASH_MODE_SCREEN()` is used without a a non-null `ScreenFlash` instance set. Also if non-`https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#OUTPUT_FORMAT_RAW_JPEG()` format is used. |

### toString

```
fun toString(): String
```

## Extension functions

### ImageCapture.takePicture

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/ImageCaptureExt.kt+function:takePicture)

```
suspend fun ImageCapture.takePicture(
    onCaptureStarted: (() -> Unit)? = null,
    onCaptureProcessProgressed: ((Int) -> Unit)? = null,
    onPostviewBitmapAvailable: ((Bitmap) -> Unit)? = null
): ImageProxy
```

Captures a new still image for in memory access.

The caller is responsible for calling `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageProxy#close()` on the returned image.

| Parameters |
|---|---|
| `onCaptureStarted: (() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Callback for when the camera has started exposing the frame. |
| `onCaptureProcessProgressed: ((https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Callback to report the progress of the capture's processing. |
| `onPostviewBitmapAvailable: ((https://developer.android.com/reference/android/graphics/Bitmap.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Callback to notify that the postview bitmap is available. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageCapturedCallback` |   |

### ImageCapture.takePicture

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/ImageCaptureExt.kt+function:takePicture)

```
suspend fun ImageCapture.takePicture(
    outputFileOptions: ImageCapture.OutputFileOptions,
    onCaptureStarted: (() -> Unit)? = null,
    onCaptureProcessProgressed: ((Int) -> Unit)? = null,
    onPostviewBitmapAvailable: ((Bitmap) -> Unit)? = null
): ImageCapture.OutputFileResults
```

Captures a new still image and saves to a file along with application specified metadata.

| Parameters |
|---|---|
| `outputFileOptions: https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OutputFileOptions` | Options to store the output image file. |
| `onCaptureStarted: (() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Callback for when the camera has started exposing the frame. |
| `onCaptureProcessProgressed: ((https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Callback to report the progress of the capture's processing. |
| `onPostviewBitmapAvailable: ((https://developer.android.com/reference/android/graphics/Bitmap.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)? = null` | Callback to notify that the postview bitmap is available. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture#takePicture(java.util.concurrent.Executor,androidx.camera.core.ImageCapture.OnImageCapturedCallback)` |   |
| `https://developer.android.com/reference/kotlin/androidx/camera/core/ImageCapture.OnImageSavedCallback` |   |