Crop Kit is a Jetpack Compose library that allows you to easily crop images. It provides a simple yet customizable crop composable to style embed it in your app seamlessly.
- Choose from a variety of crop shapes including:
- Free Form: Crop to any desired rectangular size.
- Original: Maintain image's original aspect ratio during cropping.
- Aspect Ratio: Specify any custom aspect ratio (1:1, 16:9, 4:3, etc.) for precise and consistent cropping.
- Image Transformations:
- Flip images vertically or horizontally.
- Rotate images clockwise or anti-clockwise by 90 degrees.
- Customize GridLines:
- Gridlines can be set to be always visible, be visible on touch or never be visible.
- Several types of gridlines are available such as crosshair, 3x3 grid, circle, 3x3 grid with circle.
demo.mp4
-
Add the JitPack repository to your root build.gradle file:
Kotlin DSL
dependencyResolutionManagement { ... repositories { ... maven { setUrl("https://jitpack.io") } } }
Groovy DSL
dependencyResolutionManagement { ... repositories { ... maven { url 'https://jitpack.io' } } }
-
Add the dependency:
Kotlin DSL
dependencies { implementation("com.github.Tanish-Ranjan:crop-kit:version") }
Groovy DSL
dependencies { implementation 'com.github.Tanish-Ranjan:crop-kit:version' }
-
Use the Composable:
@Composable fun ColumnScope.CropComposable() { // Create a crop controller and pass it your image bitmap val cropController = rememberCropController(bitmap = mBitmap) // Pass the controller to the ImageCropper composable ImageCropper( modifier = Modifier .fillMaxWidth() .weight(1f) .padding(24.dp), cropController = cropController ) Button( onClick = { val croppedBitmap = cropController.crop() // Handle the croppedBitmap } ) { Text("Crop") } }
See demo app for full implementation.
We welcome contributions! Please read our Contributing Guide for more information on how to get involved.
This project is licensed under the MIT License.