uCrop
uCrop copied to clipboard
Base64 Image URI causes exception
Do you want to request a feature or report a bug? Bug
What is the current behavior?
processInputUri
throws an exception when the URI is a base64 image eg. https://pastebin.com/e4ppR0NU
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.IllegalArgumentException: Invalid Uri schemedata
at com.yalantis.ucrop.task.BitmapLoadTask.processInputUri(SourceFile:165)
at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(SourceFile:87)
at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(SourceFile:36)
What is the expected behavior? Image should be loaded without an exception
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
final Uri uri = Uri.parse("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgA...A=="
UCrop.Options options = new UCrop.Options();
options.setCompressionFormat(Bitmap.CompressFormat.JPEG);
options.setCompressionQuality(100);
options.setCircleDimmedLayer(cropperCircleOverlay);
options.setFreeStyleCropEnabled(freeStyleCropEnabled);
options.setShowCropGrid(showCropGuidelines);
options.setShowCropFrame(showCropFrame);
options.setHideBottomControls(hideBottomControls);
if (cropperToolbarTitle != null) {
options.setToolbarTitle(cropperToolbarTitle);
}
if (enableRotationGesture) {
// UCropActivity.ALL = enable both rotation & scaling
options.setAllowedGestures(
UCropActivity.ALL, // When 'scale'-tab active
UCropActivity.ALL, // When 'rotate'-tab active
UCropActivity.ALL // When 'aspect ratio'-tab active
);
}
if (!disableCropperColorSetters) {
configureCropperColors(options);
}
UCrop uCrop = UCrop
.of(uri, Uri.fromFile(new File(this.getTmpDir(activity), UUID.randomUUID().toString() + ".jpg")))
.withOptions(options);
if (width > 0 && height > 0) {
uCrop.withAspectRatio(width, height);
}
uCrop.start(activity);
Please attach any image files, URL and stack trace
that can be used to reproduce the bug.
https://pastebin.com/e4ppR0NU
Which versions of uCrop, and which Android API versions are affected by this issue? Did this work in previous versions of uCrop?
Unsure about previous versions but the version in use is com.github.yalantis:ucrop:2.2.6-native