Site icon Android Tutorial Online

Image Cropper for Android Jetpack Compose

Cropify

  Lightweight image cropper for Android Jetpack Compose.

https://user-images.githubusercontent.com/9051623/231838736-8bff221e-8515-4dd4-8314-64c3166e700d.mov

Installation

  1. Add the JitPack repository to your root build.gradle.
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
  1. Add the dependency.
dependencies {
  implementation 'com.github.moyuruaizawa:cropify:${cropifyVersion}'
}

Usage

Bitmap

val state = rememberCropifyState()

Cropify(
  bitmap = imageResource(R.drawable.bitmap),
  state = state,
  onImageCropped = {},
)

Uri

val state = rememberCropifyState()

Cropify(
  uri = imageUri,
  state = state,
  onImageCropped = {},
  onFailedToLoadImage = {}
)

Invoke CropifyState#crop, the cropped image will be passed to onImageCropped. If loading an image from Uri fails, onFailedToLoadImage will be called.

Features

Customizations

Acknowledgement

I would like to thank ArthurHub/Android-Image-Cropper. Cropify aims to a Jetpack Compose implementation of ArthurHub/Android-Image-Cropper.

GitHub

View Github

Exit mobile version