[BUG] - Unable to Crop image from Uri
See original GitHub issue- Lib Version [e.g. 3.0.0]
Describe the bug First of all I would like to thank everyone involved in this library for the great work you have done. Well done.
I am currently using this library in a project where I have a personalized interface where the user can take a photo. When he takes the picture I take this uri and send it to another screen to edit the image. On this screen I have a button to crop the image, which is where I call the CropImage.
This is the contract:
fun createCropImageContract(uri: Uri): ActivityResultContract<Any?, Uri?> {
return object : ActivityResultContract<Any?, Uri?>() {
override fun createIntent(context: Context, input: Any?): Intent {
return CropImage
.activity(uri)
.getIntent(context)
}
override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
return CropImage.getActivityResult(intent)?.uriContent
}
}
}
However, when I call the method, the CropImage’s Activity is called and is immediately closed returning the Uri as null.
This is what I was able to see in the log (I don’t know if it’s related but it appears every time I press the button) :
2021-04-14 09:48:08.723 3211-3211/? E/[IndicatorGarden]Presenter: onGardenApplyWindowInsets() New DisplayCutout is NULL!!
2021-04-14 09:48:08.725 3211-3211/? E/SystemUIImageView: set Image Drawable!!
2021-04-14 09:48:08.725 3211-3211/? E/SystemUIImageView: set Background Drawable!!
2021-04-14 09:48:08.729 3211-3211/? E/[IndicatorGarden]Presenter: onGardenApplyWindowInsets() New DisplayCutout is NULL!!
2021-04-14 09:48:08.786 3211-3211/? E/[IndicatorGarden]Presenter: onGardenApplyWindowInsets() New DisplayCutout is NULL!!
2021-04-14 09:48:08.788 3211-3211/? E/SystemUIImageView: set Image Drawable!!
2021-04-14 09:48:08.788 3211-3211/? E/SystemUIImageView: set Background Drawable!!
2021-04-14 09:48:08.792 3211-3211/? E/[IndicatorGarden]Presenter: onGardenApplyWindowInsets() New DisplayCutout is NULL!!
I have another feature which is the creation of a profile, there I call this contract and everything is working correctly:
fun createCropImageContract(): ActivityResultContract<Any?, Uri?> {
return object : ActivityResultContract<Any?, Uri?>() {
override fun createIntent(context: Context, input: Any?): Intent {
return CropImage
.activity()
.getIntent(context)
}
override fun parseResult(resultCode: Int, intent: Intent?): Uri? {
return CropImage.getActivityResult(intent)?.uriContent
}
}
}
The problem is only when I already send Uri directly. Am I doing something wrong?
To Reproduce Call CropImage Passing the Uri from fragment:
CropImage
.activity(uri)
.getIntent(context)
}
Expected behavior Open the CropImage activity to crop the provided Uri
Screenshots If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
- Pixel 2 XL Android 11
- Samsung Galaxy S9+ Android 10
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (10 by maintainers)
Top GitHub Comments
@Canato Okay I think I can reproduce it because I had the issue in the past. I will look into it after a few days😊
Hi @Canato, I think this is enough, thank!
I try to use like the Glide library, want to load file path from
getUriFilePath()
into ImageViewSample video