# resizeWithContentScale

## Functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/ui/Modifier.[resizeWithContentScale](https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/modifiers/resizeWithContentScale.composable#(androidx.compose.ui.Modifier).resizeWithContentScale(androidx.compose.ui.layout.ContentScale,androidx.compose.ui.geometry.Size,androidx.compose.ui.unit.Density))( contentScale: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale, sourceSizeDp: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size?, density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density )` **This function is deprecated.** Use the overload that takes aspectRatio instead. |

## Functions

### Modifier.resizeWithContentScale

Artifact: [androidx.media3:media3-ui-compose](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/ui/compose/modifiers/extensions.kt+function:resizeWithContentScale)

```
@UnstableApi
@Composable
fun Modifier.[resizeWithContentScale](https://developer.android.com/reference/kotlin/androidx/media3/ui/compose/modifiers/resizeWithContentScale.composable#(androidx.compose.ui.Modifier).resizeWithContentScale(androidx.compose.ui.layout.ContentScale,androidx.compose.ui.geometry.Size,androidx.compose.ui.unit.Density))(
    contentScale: ContentScale,
    sourceSizeDp: Size?,
    density: Density = LocalDensity.current
): Modifier
```

> [!CAUTION]
> **This function is deprecated.**   
> Use the overload that takes aspectRatio instead, use this instead:
>
> ```kotlin
> this.resizeWithContentScale(contentScale, sourceSizeDp?.run { if (width > 0 && height > 0) width / height else null })
> ```

Attempts to size the original content rectangle to be inscribed into a destination by applying a specified `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale` type.

Use the overload that takes aspectRatio instead.

| Parameters |
|---|---|
| `contentScale: https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ContentScale` to apply to the content. |
| `sourceSizeDp: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size?` | The size of the content in DP. |
| `density: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density = LocalDensity.current` | The `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density` to use for conversions. |