Modern, Fast, and Highly Customizable Image Cropping for Jetpack Compose.
ComposeCropper is a production-ready Android library built from the ground up using Jetpack Compose. It provides a seamless image cropping experience with support for custom shapes, aspect ratios, and intuitive gestures.
- 🤏 Pinch to Zoom: Smooth multi-touch support for precise zooming.
- 🖐️ Drag to Pan: Fluid image movement within the cropper.
- 🔳 Resizable Overlay: Corner handles for intuitive crop area adjustment.
- 📐 Aspect Ratio Support: Lock to standard ratios (1:1, 16:9, etc.) or use Free mode.
- 🔴 Shape Support: Easily switch between Rectangle and Circle crop areas.
- ⚡ Double Tap to Zoom: Quick zoom-in and reset functionality.
- 🎨 Fully Customizable: Control colors, grid lines, and handle sizes.
- 🧩 Clean API: State hoisting for maximum control and integration.
Add JitPack to your settings.gradle.kts:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}Add the dependency to your build.gradle.kts:
dependencies {
implementation("com.github.YasinMoridi:ComposeCropper:1.0.3")
}val state = rememberCropperState()
val imageBitmap = ... // Load your ImageBitmap
ImageCropper(
image = imageBitmap,
state = state,
modifier = Modifier.fillMaxSize()
)
// To get the result:
val scope = rememberCoroutineScope()
Button(onClick = {
scope.launch {
val result = state.crop(imageBitmap)
if (result is CropResult.Success) {
val cropped = result.bitmap
// Use your cropped image!
}
}
}) { Text("Crop") }val state = rememberCropperState(
initialShape = CropShape.Circle
)
// Lock to 16:9 aspect ratio
state.aspectRatio = 16f / 9f
ImageCropper(
image = imageBitmap,
state = state,
overlayColor = Color.Black.copy(alpha = 0.7f),
guideLineColor = Color.Cyan
)- Rotate & Flip: Support for image rotation and mirroring.
- Edge Detection: Smart document detection using ML Kit.
- Compose Multiplatform: Support for Desktop and iOS.
- Magnifier: Loupe tool for pixel-perfect cropping.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the Apache 2.0 License. See LICENSE for more information.
Built with ❤️ for the Android Community by Yasin Moridi.