I've a question, how can i crop an image if i know the imagePath?
private val getContent = registerForActivityResult(ActivityResultContracts.GetContent()){ uri ->
val inputUri = uri
val outputUri = File(filesDir,"croppedImage.jpg").toUri()
val listUri = listOf<Uri>(inputUri,outputUri)
cropImage.launch(listUri)
}
private val uCropContract = object: ActivityResultContract<List<Uri>,Uri>(){
override fun createIntent(context: Context, input: List<Uri>): Intent {
val inputUri = input[0]
val outputUri = input[1]
val uCrop = UCrop.of(inputUri, outputUri)
.withAspectRatio(5f,5f)
.withMaxResultSize(1080,1080)
return uCrop.getIntent(context)
}
override fun parseResult(resultCode: Int, intent: Intent?): Uri {
return UCrop.getOutput(intent!!)!!
}
}
private val cropImage = registerForActivityResult(uCropContract){ uri ->
binding.imvImageAdded.setImageURI(uri)
}
I've a question, how can i crop an image if i know the imagePath?