Comments (13)
I found this while re-factoring old working code from passing the URi to passing a base64 String for the image.
The Above is when I edit a existing picture, however I did not get to the part where I create a new blog and save a new picture .
That part is actually working as intended and I have though of a work around - but it will not solve this issue.
It will however finish my project - I will keep this version for testing and work on the work around whereby I will grab the picture rendered by Glide from the view and convert that to ByteArray and then to base64 String.
If it works on making a new Blog post I will implement it on this Edit blog also.
The BUG then would be that Crop does not build the URI correctly and the extraction to bitmap fails, am I correct?
Afterthought
As I think about it the Intent to pass the picture as a base64 String will / or can blow the data parcel size
Passing the URi between Activities might be better suited to older API versions.
However sharing the picture as a base64 String to Other applications like Telegram/WhatsApp/Gmail with Implicit Intent will be OK
from android-image-cropper.
@Morons how are you calling the library? getCroppedImageAsync
?
Another question, how is the output of this logs?
Log.d(TAG, "UpdateBlogFragment: onActivityResult: result = NULL")
Log.d(TAG, "UpdateBlogFragment: onActivityResult resultUri: ${resultUri.toString()}")
Log.d(TAG, "UpdateBlogFragment: onActivityResult resultBitmap Size: ${resultBitmap?.size}")
from android-image-cropper.
One more @Morons can you check if data
is not null before call it?
from android-image-cropper.
I added
if (data == null) {
Log.d(TAG, "onActivityResult: data: Intent? is null")
} else {
Log.d(TAG, "onActivityResult: data: Intent? is not null")
}
D/AppDebug: onActivityResult: data: Intent? is not null
D/AppDebug: UpdateBlogFragment: onActivityResult: content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F84/ORIGINAL/NONE/image%2Fjpeg/1954601542
D/AppDebug: onActivityResult: data: Intent? is not null
D/AppDebug: CROP: CROP_IMAGE_ACTIVITY_REQUEST_CODE
D/AppDebug: UpdateBlogFragment: onActivityResult resultUri: content://za.co.zone.cupio.cropper.fileprovider/my_images/Pictures/cropped6023895601553057964.jpg
D/AppDebug: UpdateBlogFragment: onActivityResult resultBitmap Size: null
from android-image-cropper.
So both the original URI and the Changed URI has values -> I can access them by result?.uri
from android-image-cropper.
I can search my Pictures on the device and crop one then ........
from android-image-cropper.
private fun launchImageCrop(uri: Uri) {
context?.let {
CropImage.activity(uri)
.setGuidelines(CropImageView.Guidelines.ON)
.start(it, this)
}
}
from android-image-cropper.
@Morons I'm trying here, will put some effort to fix this! cannot guarantee will be something fast, sorry for this.
One more request, on this lines:
resultBitmap = result?.bitmap?.toByteArray()
Log.d(TAG, "UpdateBlogFragment: onActivityResult resultBitmap Size: ${resultBitmap?.size}")
Can you do:
resultBitmap = result?.bitmap
Log.d(TAG, "UpdateBlogFragment: onActivityResult resultBitmap Size: ${resultBitmap?}")
val array = resultBitmap?.toByteArray()
Log.d(TAG, "UpdateBlogFragment: onActivityResult resultBitmap Size: ${array?}")
Please! But will try to solve. In any case, if you have time, you can check the library code and try to solve. So we can release =)
Will tag here @CanHub/imagecropcollaborators if anyone have time to check this, interesting bug
from android-image-cropper.
CROP_IMAGE_ACTIVITY_REQUEST_CODE -> {
val resultBitmap: Bitmap?
Log.d(BaseBlogFragment.TAG, "CROP: CROP_IMAGE_ACTIVITY_REQUEST_CODE: ${CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE}")
val result = CropImage.getActivityResult(data)
if (result == null) {
Log.d(BaseBlogFragment.TAG, "UpdateBlogFragment: onActivityResult: result = NULL")
}
val resultUri = result?.uri
Log.d(BaseBlogFragment.TAG, "UpdateBlogFragment: onActivityResult resultUri: ${resultUri.toString()}")
resultBitmap = result?.bitmap
Log.d(BaseBlogFragment.TAG, "UpdateBlogFragment: onActivityResult resultBitmap Bitmap: $resultBitmap")
val array = resultBitmap?.toByteArray()
Log.d(BaseBlogFragment.TAG, "UpdateBlogFragment: onActivityResult resultBitmap array: $array")
val resultImage: String = Base64.decode(array, Base64.DEFAULT).decodeToString()
viewModel.setUpdatedUri(resultImage)
}
Results AppDebug
onActivityResult: data: Intent? is not null
D/AppDebug: UpdateBlogFragment: onActivityResult: before crop: content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F78/ORIGINAL/NONE/image%2Fwebp/1182126952
D/AppDebug: onActivityResult: data: Intent? is not null
D/AppDebug: CROP: CROP_IMAGE_ACTIVITY_REQUEST_CODE: 203
D/AppDebug: UpdateBlogFragment: onActivityResult resultUri: content://za.co.zone.cupio.cropper.fileprovider/my_images/Pictures/cropped7735694781174099916.jpg
D/AppDebug: UpdateBlogFragment: onActivityResult resultBitmap Bitmap: null
D/AppDebug: UpdateBlogFragment: onActivityResult resultBitmap array: null
from android-image-cropper.
@Morons totally, will work on fixing this ASAP
from android-image-cropper.
Any progress? fixing the bitmap output from CropImage
from android-image-cropper.
Any progress? fixing the bitmap output from CropImage
Not yet @Morons I'm very busy with normal work and changing jobs.
But on Monday I added new code on the sample that should make easy to reproduce this and fix.
You can jump in if you feel like, otherwise will need to wait a little.
I would love to be faster to tackle the bugs, but this code was 2 years without update when I handover so I need to have more time adding it structure so I'm sure I'm not breaking anything with the changes we add.
In any case, sorry for the delay, but be sure I'm putting as much time I can to improve it =)
from android-image-cropper.
@Morons I was taking a look with more attention today.
We have an issue because a bitmap is a huge data to pass between activities. When you try to get getOriginalBitmap
we have the documentation:
Null if uri used to load image or activity result is used.
I was trying to improve this, creating a bitmap, but is too huge for the Parcel
in the result activity.
So the solution for the library is to have a new method that will need the context to get the bitmap from the internal uri. Hope this solve you problem. is coming on next release 2.1.1
as soon the tickets are merged
from android-image-cropper.
Related Issues (20)
- Get position Highlight Cropper.
- e HOT 1
- Build failing since version 4.3.3 HOT 1
- Managing cache file HOT 4
- Is this repo still being supported or not? HOT 1
- CropImageView fails to respect the match_parent size upon resizing the window HOT 1
- ActivityResultContract for custom activity
- Can I Customize Crip Edit Screen In Android Compose? HOT 1
- URI validation security issue
- Crashing on calling the copping activity...
- Multiple call of cropImage in loop when we can pick more then one image from gallery
- Getting crash while selection of camera cropping only in Android 10
- Question : Is it possible move and scale the picture itself instead of the crop overlay? HOT 3
- v
- Can crop by path or region? HOT 1
- Prevent CropRect Translation in Image Cropper
- Tool bar and its buttons(back, crop etc) is not shown. just white space HOT 2
- [Feature Request] Support for Rounded Rectangle Crop Shape HOT 4
- Integrate the Photo picker tool HOT 1
- Opening camera doesn't allow exiting the activity HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-image-cropper.