Android-Image-Cropper icon indicating copy to clipboard operation
Android-Image-Cropper copied to clipboard

How to use CropImageView in Compose?

Open phongbm opened this issue 2 years ago • 2 comments

I want to use CropImageView in Compose project, how to do that?

phongbm avatar Oct 30 '23 00:10 phongbm

Like this:

val cropImage = rememberLauncherForActivityResult(CropImageContract()) { result -> if (result.isSuccessful) { // Use the returned uri. val uriContent = result.uriContent val uriFilePath = result.getUriFilePath(context) // optional usage } else { // An error occurred. val exception = result.error } }

and start with e.g. this:

cropImage.launch( CropImageContractOptions( uri = null, cropImageOptions = CropImageOptions( imageSourceIncludeGallery = true, imageSourceIncludeCamera = false, fixAspectRatio = true // aspectRatioX = 1, // aspectRatioY = 1, ) ) )

Pantsoffski avatar Dec 20 '23 19:12 Pantsoffski

https://gist.github.com/hoangchungk53qx1/b17356cc82515666058b3d53781bf5d5

hoangchungk53qx1 avatar Jun 03 '24 02:06 hoangchungk53qx1

Seems like there is a solution. We don't have official Compose support, but I'm willing to take PRs that either improve the overall component / provide a proper Compose support.

vanniktech avatar Aug 05 '24 08:08 vanniktech