Comments (20)
Hey @immujahidkhan could you please give us more information about the bug?
Please fill the template, otherwise I cannot understand where this happen, if was from the library, which way are you using the library etc.
Bug Template
- Lib Version [e.g. 1.1.0]
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Smartphone (please complete the following information):**
- Device: [e.g. Pixel 3XL]
- OS: [e.g. iOS8.1]
**Additional context**
Add any other context about the problem here.
from android-image-cropper.
@immujahidkhan I could not reproduce on the sample app in this library. You could try?
This do not look like a library issue, but maybe you code is trying to access the file
where now is content
since the last Android changes for permissions in OS 10 and OS 11.
You can read more here
Let me know if this is the same case or a new one
from android-image-cropper.
i want to setImageURI like binding.userPhoto.setImageURI(result.getUri());
but can't
from android-image-cropper.
i want to setImageURI like
binding.userPhoto.setImageURI(result.getUri());
but can't
Can you post the code where the exception is being throwing? (the one on the screenshot)
And please show the code where you are calling the library and retrieving the result. So I can understand how you are using it
from android-image-cropper.
i want to setImageURI like
binding.userPhoto.setImageURI(result.getUri());
but can't
you can use
binding.userPhoto.setImageBitmap(BitmapFactory.decodeFile(result.getUri().getPath()));
from android-image-cropper.
I am facing the same issue when I am uploading images to the server in multipart/form-data.
Error message: ENOENT(No such file or directory)
Libray version: 2.3.1
from android-image-cropper.
I am facing the same issue when I am uploading images to the server in multipart/form-data.
Error message: ENOENT(No such file or directory)
Libray version: 2.3.1
- Can you please provide code sample?
- Can you reproduce on the sample app in this repository?
- Did you read the uri discussion ?
from android-image-cropper.
- I am getting the image from the device gallery. and then pass the URI of this image into the library like this:
CropImage.INSTANCE.activity(imageUri).start(requireContext(), this)
- And after crop I am getting the result into onActivityResult and save the URI that I got from this :
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.INSTANCE.getActivityResult(data); Uri resultUri; if (result != null) { resultUri = result.getUri(); final InputStream imageStream; try { imageStream = requireActivity().getContentResolver().openInputStream(resultUri); final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream); delete_icon.setVisibility(View.VISIBLE); edit_icon.setVisibility(View.VISIBLE); Picasso.get().load(resultUri).resize(720, 1280).onlyScaleDown().into(imageView); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
- I am saving the resultUri into the list but when I convert this URI into multipart/form-data and send the response t server then it shows me this error ENOENT(No such file or directory)
from android-image-cropper.
I also getting error Error: open failed: ENOENT (No such file or directory), i think it's because save in shared storage
from android-image-cropper.
Changes to be done here: #107
from android-image-cropper.
Please try the latest 3.0.0
release and let me know
from android-image-cropper.
Hi @Canato i already implement 3.0.0
but still show
java.lang.RuntimeException: Failed to load sampled bitmap: content://com.android.cropper.fileprovider/my_images/Pictures/pickImageResult.jpeg
System.err: open failed: ENOENT (No such file or directory)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Uri uri = CropImage.getPickImageResultUriContent(activity, data);
CropImage.ActivityBuilder crop = CropImage.activity(uri).start(activity);
}
problem on Samsung A71 and Samsung M31 Android 11
already add permission scope storage mean
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
i don't know how to fixed this, please help me
thank you
from android-image-cropper.
@fajar2304 if you want the FilePath, please use getPickImageResultUriFilePath
and not getPickImageResultUriContent
Let me know if works please
from android-image-cropper.
@Canato thank you for respond, sorry still not working
java.lang.RuntimeException: Failed to load sampled bitmap: /data/user/0/com.android.crop/cache/temp_file.jpg
System.err: No content provider: /data/user/0/com.android.crop/cache/temp_file.jpg
from android-image-cropper.
@fajar2304 can you do a test in something manual please? If works I can make a hotfix
add file://
to the string. Meaning: /data/user/0/com.android.crop/cache/temp_file.jpg
will became file:///data/user/0/com.android.crop/cache/temp_file.jpg
from android-image-cropper.
@Canato still error like this
java.lang.RuntimeException: Failed to load sampled bitmap: file:///data/user/0/com.android.crop/cache/temp_file.jpg
System.err: File is not a picture
but before show this first log show like this
java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
System.err: at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:344)
System.err: at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:231)
System.err: at androidx.core.content.FileProvider.openFile(SourceFile:566)
System.err: at android.content.ContentProvider.openAssetFile(ContentProvider.java:2032)
System.err: at android.content.ContentProvider.openTypedAssetFile(ContentProvider.java:2214)
System.err: at android.content.ContentProvider.openTypedAssetFile(ContentProvider.java:2281)
System.err: at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:558)
System.err: at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2010)
System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1825)
System.err: at android.content.ContentResolver.openInputStream(ContentResolver.java:1502)
System.err: at e.d.a.j.a.c(SourceFile:41)
System.err: at e.d.a.j.a.d(SourceFile:26)
System.err: at com.canhub.cropper.CropImage.i(SourceFile:406)
System.err: at e.s.a.a.e.h.b(SourceFile:77)
System.err: at com.android.crop.Camera.onActivityResult(SourceFile:286)
System.err: at android.app.Activity.dispatchActivityResult(Activity.java:8508)
System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:5150)
System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:5198)
System.err: at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2135)
System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
System.err: at android.os.Looper.loop(Looper.java:236)
System.err: at android.app.ActivityThread.main(ActivityThread.java:8060)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
from android-image-cropper.
@fajar2304 I will need to take a look with more time.
If you have the chance please reproduce this bug on the sample code. Hard for me to debug if I can't reproduce locally =/
And open a new issue, so we can make visible for everyone =D
from android-image-cropper.
I was able to solve this issue
by first converting result uri into bitmap then save it to file.
` ActivityResultLauncher<CropImageContractOptions> cropImageContractOptionsActivityResultLauncher = registerForActivityResult(new CropImageContract(), result -> {
if (result.isSuccessful()) {
uriContent = result.getUriContent();
Bitmap bitmap = Helper.getBitmap(this, uriContent);
File selectedImgFile = new File(
getExternalFilesDir(Environment.DIRECTORY_PICTURES),
Timing.getCurrentTimeEpoch() + "_selectedImg.jpg");
Helper.convertBitmapToFile(selectedImgFile, bitmap);
profileViewmodel.uploadimage(selectedImgFile.getPath());
} else {
showMessage(R.string.failed_to_upload);
}
});`
public static Bitmap getBitmap(Context context, Uri imageURI) {
try {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
return ImageDecoder.decodeBitmap(ImageDecoder.createSource(context.getContentResolver(), imageURI));
} else {
InputStream
inputStream = context.getContentResolver().openInputStream(imageURI);
return BitmapFactory.decodeStream(inputStream);
}
} catch (Exception e) {
return null;
}
}
public static void convertBitmapToFile(File dFile, Bitmap bitmap) {
try {
//create a file to write bitmap data
boolean newFile = dFile.createNewFile();
//Convert bitmap to byte array
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
//write the bytes in file
FileOutputStream fileOutputStream = new FileOutputStream(dFile);
fileOutputStream.write(bytes);
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception e) {
Log.d(Helper.class.getSimpleName(), e.getLocalizedMessage());
}
}
from android-image-cropper.
I was able to solve this issue by first converting result uri into bitmap then save it to file.
` ActivityResultLauncher<CropImageContractOptions> cropImageContractOptionsActivityResultLauncher = registerForActivityResult(new CropImageContract(), result -> { if (result.isSuccessful()) { uriContent = result.getUriContent(); Bitmap bitmap = Helper.getBitmap(this, uriContent); File selectedImgFile = new File( getExternalFilesDir(Environment.DIRECTORY_PICTURES), Timing.getCurrentTimeEpoch() + "_selectedImg.jpg"); Helper.convertBitmapToFile(selectedImgFile, bitmap); profileViewmodel.uploadimage(selectedImgFile.getPath()); } else { showMessage(R.string.failed_to_upload); } });`
public static Bitmap getBitmap(Context context, Uri imageURI) { try { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { return ImageDecoder.decodeBitmap(ImageDecoder.createSource(context.getContentResolver(), imageURI)); } else { InputStream inputStream = context.getContentResolver().openInputStream(imageURI); return BitmapFactory.decodeStream(inputStream); } } catch (Exception e) { return null; } } public static void convertBitmapToFile(File dFile, Bitmap bitmap) { try { //create a file to write bitmap data boolean newFile = dFile.createNewFile(); //Convert bitmap to byte array ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, byteArrayOutputStream); byte[] bytes = byteArrayOutputStream.toByteArray(); //write the bytes in file FileOutputStream fileOutputStream = new FileOutputStream(dFile); fileOutputStream.write(bytes); fileOutputStream.flush(); fileOutputStream.close(); } catch (Exception e) { Log.d(Helper.class.getSimpleName(), e.getLocalizedMessage()); } }
Seems like this is the workaround so far. Though I will rather create a temporary file. I am getting this issue on Android 12 on Pixel 5.
from android-image-cropper.
please open a new issue with the bug template and the reproduce behaviour on the sample code so we can take a look =D
from android-image-cropper.
Related Issues (20)
- 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
- How to customize the AlertDialog in Jetpack Compose? HOT 3
- Allow selecting multiple images at a time from the Gallery HOT 3
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.