Skip to content

YasinMoridi/ComposeCropper

Repository files navigation

📸 ComposeCropper

Modern, Fast, and Highly Customizable Image Cropping for Jetpack Compose.

Kotlin Version Compose Version License

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.


✨ Features

  • 🤏 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.

🚀 Quick Start

1. Installation

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")
}

2. Basic Usage

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") }

🛠 Advanced Configuration

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
)

🗺 Roadmap

  • 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.

🤝 Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

Distributed under the Apache 2.0 License. See LICENSE for more information.


Built with ❤️ for the Android Community by Yasin Moridi.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages