
Robust, easy-to-use library for cropping images with a single codebase, featuring a user-friendly UI and supporting both Android and Desktop platforms.
Kotlin Multiplatform Image Cropper is a robust, easy-to-use library designed for image cropping across Android, iOS, and other platforms using the Kotlin Multiplatform Mobile (KMM) technology.
Add dependency in your module build.gradle
dependencies {
implementation("io.github.marwanm7moud:cropper:$latest_release")
}@Composable
fun ImageCropperSample(){
var crop by remember { mutableStateOf(false) }
var isCropping by remember { mutableStateOf(false) }
var croppedImage by remember { mutableStateOf<ImageBitmap?>(null) }
var filePath = "" //add here your file path
Box(
modifier = Modifier.fillMaxSize().background(Color.Black),
contentAlignment = Alignment.Center
) {
ImageCropper(
modifier = Modifier.fillMaxSize(0.7f),
imagePath = filePath,
onCropStart = {
isCropping = true
},
onCropSuccess = {
croppedImage = it
isCropping = false
crop = false
},
crop = crop
)
Button(
onClick = {
crop = true
},
modifier = Modifier
.padding(16.dp).align(Alignment.TopEnd)
) {
Text("Crop Image")
}
// Display the cropped image if available
croppedImage?.let { cropped ->
Image(
bitmap = cropped,
contentDescription = null,
modifier = Modifier
.size(200.dp, 200.dp).align(Alignment.TopStart) // Adjust the size as needed
)
}
}
}@Composable
fun ImageCropperSample(image:ImageBitmap){
var crop by remember { mutableStateOf(false) }
var isCropping by remember { mutableStateOf(false) }
var croppedImage by remember { mutableStateOf<ImageBitmap?>(null) }
Box(
modifier = Modifier.fillMaxSize().background(Color.Black),
contentAlignment = Alignment.Center
) {
ImageCropper(
modifier = Modifier.fillMaxSize(0.7f),
image = image,
onCropStart = {
isCropping = true
},
onCropSuccess = {
croppedImage = it
isCropping = false
crop = false
},
crop = crop
)
Button(
onClick = {
crop = true
},
modifier = Modifier
.padding(16.dp).align(Alignment.TopEnd)
) {
Text("Crop Image")
}
// Display the cropped image if available
croppedImage?.let { cropped ->
Image(
bitmap = cropped,
contentDescription = null,
modifier = Modifier
.size(200.dp, 200.dp).align(Alignment.TopStart) // Adjust the size as needed
)
}
}
}Kotlin Multiplatform Image Cropper is a robust, easy-to-use library designed for image cropping across Android, iOS, and other platforms using the Kotlin Multiplatform Mobile (KMM) technology.
Add dependency in your module build.gradle
dependencies {
implementation("io.github.marwanm7moud:cropper:$latest_release")
}@Composable
fun ImageCropperSample(){
var crop by remember { mutableStateOf(false) }
var isCropping by remember { mutableStateOf(false) }
var croppedImage by remember { mutableStateOf<ImageBitmap?>(null) }
var filePath = "" //add here your file path
Box(
modifier = Modifier.fillMaxSize().background(Color.Black),
contentAlignment = Alignment.Center
) {
ImageCropper(
modifier = Modifier.fillMaxSize(0.7f),
imagePath = filePath,
onCropStart = {
isCropping = true
},
onCropSuccess = {
croppedImage = it
isCropping = false
crop = false
},
crop = crop
)
Button(
onClick = {
crop = true
},
modifier = Modifier
.padding(16.dp).align(Alignment.TopEnd)
) {
Text("Crop Image")
}
// Display the cropped image if available
croppedImage?.let { cropped ->
Image(
bitmap = cropped,
contentDescription = null,
modifier = Modifier
.size(200.dp, 200.dp).align(Alignment.TopStart) // Adjust the size as needed
)
}
}
}@Composable
fun ImageCropperSample(image:ImageBitmap){
var crop by remember { mutableStateOf(false) }
var isCropping by remember { mutableStateOf(false) }
var croppedImage by remember { mutableStateOf<ImageBitmap?>(null) }
Box(
modifier = Modifier.fillMaxSize().background(Color.Black),
contentAlignment = Alignment.Center
) {
ImageCropper(
modifier = Modifier.fillMaxSize(0.7f),
image = image,
onCropStart = {
isCropping = true
},
onCropSuccess = {
croppedImage = it
isCropping = false
crop = false
},
crop = crop
)
Button(
onClick = {
crop = true
},
modifier = Modifier
.padding(16.dp).align(Alignment.TopEnd)
) {
Text("Crop Image")
}
// Display the cropped image if available
croppedImage?.let { cropped ->
Image(
bitmap = cropped,
contentDescription = null,
modifier = Modifier
.size(200.dp, 200.dp).align(Alignment.TopStart) // Adjust the size as needed
)
}
}
}