# ImageInfo

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/ImageInfo.java+class:androidx.camera.core.ImageInfo) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***


```
public interface ImageInfo
```

<br />

*** ** * ** ***

Metadata for an image.

## Summary

| ### Public methods |
|---|---|
| `default int` | `https://developer.android.com/reference/androidx/camera/core/ImageInfo#getFlashState()()` Returns the `https://developer.android.com/reference/androidx/camera/core/FlashState` value corresponding to the image capture. |
| `abstract int` | `https://developer.android.com/reference/androidx/camera/core/ImageInfo#getRotationDegrees()()` Returns the rotation needed to transform the image to the correct orientation. |
| `default @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Matrix.html` | `https://developer.android.com/reference/androidx/camera/core/ImageInfo#getSensorToBufferTransformMatrix()()` Returns the sensor to image buffer transform matrix. |
| `abstract long` | `https://developer.android.com/reference/androidx/camera/core/ImageInfo#getTimestamp()()` Returns the timestamp of the metadata. |

## Public methods

### getFlashState

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

```
default int getFlashState()
```

Returns the `https://developer.android.com/reference/androidx/camera/core/FlashState` value corresponding to the image capture.

Value is one of the following:

- `0`
- `1`
- `2`
- `3`

<br />

### getRotationDegrees

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

```
abstract int getRotationDegrees()
```

Returns the rotation needed to transform the image to the correct orientation.

This is a clockwise rotation in degrees that needs to be applied to the image buffer. Note that for images that are in `https://developer.android.com/reference/android/graphics/ImageFormat.html#JPEG` this value will match the rotation defined in the EXIF.

The target rotation is set at the time the image capture was requested.

The correct orientation of the image is dependent upon the producer of the image. For example, if the `https://developer.android.com/reference/androidx/camera/core/ImageProxy` that contains this instance of ImageInfo is produced by an `https://developer.android.com/reference/androidx/camera/core/ImageCapture`, then the rotation will be determined by `https://developer.android.com/reference/androidx/camera/core/ImageCapture#setTargetRotation(int)` or `https://developer.android.com/reference/androidx/camera/core/ImageCapture.Builder#setTargetRotation(int)`.

| Returns |
|---|---|
| `int` | The rotation in degrees which will be a value in {0, 90, 180, 270}. |

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

### getSensorToBufferTransformMatrix

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

```
default @NonNull Matrix getSensorToBufferTransformMatrix()
```

Returns the sensor to image buffer transform matrix.

The returned matrix is a mapping from sensor coordinates to buffer coordinates, which is, from the value of `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE` to `(0, 0, image.getWidth, image.getHeight)`. The matrix can be used to map the coordinates from one `https://developer.android.com/reference/androidx/camera/core/UseCase` to another. For example, mapping coordinates of the face detected with `https://developer.android.com/reference/androidx/camera/core/ImageAnalysis` to `https://developer.android.com/reference/androidx/camera/core/ImageCapture`. If `https://developer.android.com/reference/androidx/camera/core/ImageAnalysis.Builder#setOutputImageRotationEnabled(boolean)` is set to false, `https://developer.android.com/reference/androidx/camera/core/ImageInfo#getRotationDegrees()` will return the rotation degree that needs to be applied to the image buffer to user. In this case, the transform matrix can be calculated using rotation degrees. If `https://developer.android.com/reference/androidx/camera/core/ImageAnalysis.Builder#setOutputImageRotationEnabled(boolean)` is set to true, the ImageAnalysis pipeline will apply the rotation to the image buffer and `https://developer.android.com/reference/androidx/camera/core/ImageInfo#getRotationDegrees()` will always return 0. In this case, the transform matrix cannot be calculated. This API provides the transform matrix which could handle both cases.

```
        // Calculate the matrix
        Matrix analysisToSensor = new Matrix();
        analysisToSensor.invert(
            imageAnalysisImageProxy.getImageInfo()
                                   .getSensorToBufferTransformMatrix());
        Matrix sensorToCapture = captureImageProxy.getImageInfo()
                                                  .getSensorToBufferTransformMatrix();
        Matrix analysisToCapture = new Matrix();
        analysisToCapture.setConcat(analysisToSensor, sensorToCapture);

        // Transforming the coordinates
        Rect faceBoundingBoxInAnalysis;
        Rect faceBoundingBoxInCapture;
        analysisToCapture.mapRect(faceBoundingBoxInAnalysis, faceBoundingBoxInCapture);

        // faceBoundingBoxInCapture is the desired value
    
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Matrix.html` | the transform matrix. |

### getTimestamp

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

```
abstract long getTimestamp()
```

Returns the timestamp of the metadata. Details on the timestamp depend on the source providing the image, and the method providing the image contains more documentation.

| Returns |
|---|---|
| `long` | the timestamp of the image |