Comments (8)
Hi,
In my case I solved the problem following this:
https://developer.android.com/training/data-storage/shared/documents-files?hl=es-419
Hope it helps you too!
Regards,
from android-image-cropper.
Hey @RanjitPati I'm on holidays for the next weeks, but this don't look like a library issue.
The URI is returning correctly, since you can put it on the ImageView, like you said.
I cannot see the code to create the file, but maybe you can't create the file using the same URI because of the Android Scope Storage, something to check.
The bug here would be wrong URI value return, but this is working.
So not sure what the bug could be.
Open to discussions so we can solve this and help you =D
from android-image-cropper.
I am creating the file like new File(uri.getPath())
. The same code was working before. @TomasMVazquez Can you please share the piece of code which you have used to create the file from the uri.
from android-image-cropper.
I am creating the file like
new File(uri.getPath())
. The same code was working before. @TomasMVazquez Can you please share the piece of code which you have used to create the file from the uri.
@RanjitPati maybe this is happening because of Android OS permission changes.
Now using scope storage we don't get a file path anymore.
Maybe you can change the URI string "content" to "file"
But is not the real fix, the library will return the URI for the image using the scope storage like google force us now.
If you plan to create a file you need to get write storage permission and get the path where you put the image.
Make sense?
from android-image-cropper.
com.theartofdev.edmodo:android-image-cropper:2.8.0
It works here pretty fine, you can check this library for you reference.
from android-image-cropper.
I am creating the file like
new File(uri.getPath())
. The same code was working before. @TomasMVazquez Can you please share the piece of code which you have used to create the file from the uri.
What I needed was to get Base64 from Uri/Path, originaly I was getting the path but with the change I'm using directly the Uri:
Original Code:
fun imageFileToBase64(imageFile: File): String {
return FileInputStream(imageFile).use { inputStream ->
ByteArrayOutputStream().use { outputStream ->
Base64OutputStream(outputStream, Base64.DEFAULT).use { base64FilterStream ->
inputStream.copyTo(base64FilterStream)
base64FilterStream.flush()
outputStream.toString()
}
}
}
}
New Code:
fun imageUriToBase64(context: Context, uri: Uri): String? {
val contentResolver = context.contentResolver
return contentResolver.openInputStream(uri)?.use { inputStream ->
ByteArrayOutputStream().use { outputStream ->
Base64OutputStream(outputStream, Base64.DEFAULT).use { base64FilterStream ->
inputStream.copyTo(base64FilterStream)
base64FilterStream.flush()
outputStream.toString()
}
}
}
}
from android-image-cropper.
com.theartofdev.edmodo:android-image-cropper:2.8.0
It works here pretty fine, you can check this library for you reference.
This was the main reason I fork from the old library @AbdulmalekAlshugaa , this was the way it work before OS 11.
Now with OS 11, this behaviour changed so the library was updated, not we need to update the usage of it too.
Please let's put all discussion about this on the same place: https://github.com/CanHub/Android-Image-Cropper/discussions/87
Sadly this is an Android OS change, but if anyone know a better fix for the latest OS, using scope storage and keeping it file
drop a PR cause will help everyone =)
I will close so we focus the discussion on the same place
https://github.com/CanHub/Android-Image-Cropper/discussions/87
from android-image-cropper.
Please try the latest 3.0.0
release and let me know
from android-image-cropper.
Related Issues (20)
- I Dont have any issue i have a question
- 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
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.