# ImageWrappers

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/ImageWrapper.kt+class:androidx.camera.common.ImageWrappers) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
object ImageWrappers
```

<br />

*** ** * ** ***

Utility methods for `https://developer.android.com/reference/kotlin/androidx/camera/common/ImageWrapper`.

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/MutableImageWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/ImageWrappers#wrap(android.media.Image)(image: https://developer.android.com/reference/android/media/Image.html)` Wraps a native `https://developer.android.com/reference/android/media/Image.html` into a `https://developer.android.com/reference/kotlin/androidx/camera/common/MutableImageWrapper`. |

## Public functions

### wrap

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

```
fun wrap(image: Image): MutableImageWrapper
```

Wraps a native `https://developer.android.com/reference/android/media/Image.html` into a `https://developer.android.com/reference/kotlin/androidx/camera/common/MutableImageWrapper`.

```kotlin
import androidx.camera.common.ImagePlane
import androidx.camera.common.ImageWrappers
import androidx.camera.common.MutableImageWrapper

// Wrap a native android.media.Image into a MutableImageWrapper.
val imageWrapper: MutableImageWrapper = ImageWrappers.wrap(image)

// Inspect image metadata:
val width: Int = imageWrapper.width
val height: Int = imageWrapper.height
val format: Int = imageWrapper.format
val timestamp: Long = imageWrapper.timestamp
val planes: List<ImagePlane> = imageWrapper.imagePlanes

// Optionally update mutable properties such as cropRect:
imageWrapper.cropRect = Rect(0, 0, width / 2, height / 2)

// Always close the wrapper to release native resources:
imageWrapper.close()
```