arthurhub / android-image-cropper Goto Github PK
View Code? Open in Web Editor NEWImage Cropping Library for Android, optimized for Camera / Gallery.
License: Apache License 2.0
Image Cropping Library for Android, optimized for Camera / Gallery.
License: Apache License 2.0
Hi,
thanks for you library!
It works very well.
There is a way to start the crop rectangle to completly fit the image?
So the user is not forced to expand it if the photo is already correct.
Thaks!
Davide
Are there any plans for future versions? Enhancements...?
If the selected image has an Alpha channel (transparent section) the transparent pixels are discarded during crop, and replaced with black pixels.
This may be a function of the BitmapRegionDecoder configuration.
Hello,
I tried to get a bitmap using the method getCroppedImage(), but since I was a turn counterclockwise (-90 degrees), for some reason he does not appear. Since turning clockwise all works well.
cropImageView.rotateImage(-90);
Dear Arthur,
first of all i thank you for developing such a nice library.
Recently, i have changed my cell phone to new Nexus 5x and faced the problem that capturing the picture with native google camera2 app does not load image after capture.
I would really appreciate if you care about this issue.
thnx
Hello,
Do you know how to use your library and allow for the user to zoom into the image before cropping?
Thanks,
Anshul
First, thank you so much for this library. It's awesome and using it with my app. But I just got this error from Crashlytics from the field. Sounds like an incompatible binary with source. Does the library just need to be rebuilt and published to maven?
java.lang.IncompatibleClassChangeError: interface not implemented
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.closeSafe(ImageViewUtil.java:252)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.getFileFromUri(ImageViewUtil.java:225)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.rotateBitmapByExif(ImageViewUtil.java:94)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:293)
at com.gameontechnology.gameon.ui.activity.PhotoPickerActivity.onActivityResult(PhotoPickerActivity.java:88)
at android.app.Activity.dispatchActivityResult(Activity.java:4670)
Will be cool to start an activity with the image somehow and receive it somehow after crop without adding ml views.
How can i set min/max crop height ?
tried like for oval shape
cropImageView.setImageBitmap(bitmapOrignal);
cropImageView.setCropShape(CropImageView.CropShape.OVAL);
bitmapOrignal=cropImageView.getCroppedImage();
iv_toedit.setImageBitmap(bitmapOrignal);
tried like for rectangle
cropImageView.setImageBitmap(bitmapOrignal); cropImageView.setCropShape(CropImageView.CropShape.RECTANGLE); bitmapOrignal=cropImageView.getCroppedImage(); iv_toedit.setImageBitmap(bitmapOrignal);
The readme.md says to see the "linked GitHub Wiki" at https://github.com/ArthurHub/Android-Image-Cropper/wiki/Android-Image-Cropper but it's empty? It would be very nice to see all available methods in the wiki.
When setting the crop shape to oval - setCropShape(CropImageView.CropShape.OVAL)
- the touch points to resize are not what I'd expect. It looks like it may still have the typical square touch points.
Red points indicate failed resize attempts. Green = successful.
Am going to try to dig into this myself and submit a PR. Any help pointing in the right direction would be awesome!
<com.theartofdev.edmodo.cropper.CropImageView
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/cropImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
custom:cropScaleType="fitCenter"
custom:cropGuidelines="onTouch"
custom:cropFixAspectRatio="true"
custom:cropBorderLineThickness="1dp"
custom:cropBorderCornerThickness="1dp"
custom:cropMinCropWindowWidth="1px"
custom:cropMinCropWindowHeight="1px"/>
All of the attrs work except the min crop window ones. I have tried both dp and px. Looking in the src, it looks like the default is 40.
I have that exception: java.lang.RuntimeException: Canvas: trying to use a recycled bitmap
Currently in our app we have an attribute called backgroundColor
which collides with the attribute in this library (https://github.com/ArthurHub/Android-Image-Cropper/blob/master/cropper/src/main/res/values/attrs.xml). Thoughts on changing this/adding prefixes to the attributes?
custom:cropShowGuidelines="onTouch" throws error during compile.
While selecting faces out of photographs, its good to be able to zoom in / out before aligning the oval/rectangle. How can that be done with this lib ?
Genymotion Android 5.0 emulator
Launch the sample app an rotate or app switch. A crash occurs:
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@d10b73c
The same crash manifests on 4.1.1, 4.3, 4.4.2, and 5.1 only on rotation.
I need both: A circle (not an oval) and also a square (not rectangle).
How can this be done?
If set OVAL shape, on some old androids (like 15, and 16 API I tested)
canvas.clipPath(circleSelectionPath, Region.Op.XOR); work bad, we have completely all image darken. I ggogled and found solution - we have to turn off hardware acceleration and it would work as it should. So, fix is
if (Build.VERSION.SDK_INT <= 19 && mCropShape == CropImageView.CropShape.OVAL) {
//TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
Full code -
public void setCropShape(CropImageView.CropShape cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT <= 19 && mCropShape == CropImageView.CropShape.OVAL) {
//TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
invalidate();
}
AND in drawBackground method :
Path circleSelectionPath = new Path();
mRectF.set(l, t, r, b);
if (Build.VERSION.SDK_INT <= 19 && mCropShape == CropImageView.CropShape.OVAL) {
mRectF.set(l + UIHelper.getPixel(2), t + UIHelper.getPixel(2), r - UIHelper.getPixel(2), b - UIHelper.getPixel(2));
}
circleSelectionPath.addOval(mRectF, Path.Direction.CW);
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.clipPath(circleSelectionPath, Region.Op.XOR);
canvas.drawRect(bitmapRect.left, bitmapRect.top, bitmapRect.right, bitmapRect.bottom, mBackgroundPaint);
canvas.restore();
Plese push this to repo
If you have any question, please contact me, I will help ^)
You have pretty good lib)
I believe with the latest updates, I've started seeing odd behavior with the circle crop shape where it changes to an oval shape after attempting to resize. This seems to happen on low-res images where the crop circle shape is "maxed out" so-to-speak (when viewing, the circle shape is extended as large as the photo itself).
To reproduce, try cropping the following image using the oval shape with a Fixed AspectRatio (you may need to click outside the bounds):
after croping and rotaing how to save image into gallery in the new folder
Is it possible to manually set the position and size of the cropping shape? For example if I want to use the cropper in combination with face detection and center the initial cropping rectangle around the face of a person.
Tanks!
Is it possible to add a enhancement which would allow me to change the border, guidelines and corner colors? That would be helpful to use the brand identity colors.
Thanks
When I use
mImageCropperView.setFixedAspectRatio(true); mImageCropperView.setAspectRatio(1, 1);
and the crop window is touching two adjacent sides of the image, it is not possible to expand the crop window further.
In other words, when the crop window is at a corner of the image, I'm not able to expand it even though there is more space for it to expand.
This is a really weird behaviour. I hope it gets improved in future updates.
When using the CropImageView for a shared element transition, the guidelines will show during the transition. It would be nice to work around that somehow.
Idea: Add enableCropping/disableCropping methods to the view. Disabling will hide the guidelines, enabling will return them. Is there any reason not to add something like this?
Thanks for the great library! after selecting an image from gallery and performing crop action this is what I see in my logcat:
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: java.lang.RuntimeException: Failed to load sampled bitmap: content://com.android.providers.media.documents/document/image%3A74085
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:212)
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: at com.theartofdev.edmodo.cropper.BitmapCroppingWorkerTask.doInBackground(BitmapCroppingWorkerTask.java:153)
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: at com.theartofdev.edmodo.cropper.BitmapCroppingWorkerTask.doInBackground(BitmapCroppingWorkerTask.java:25)
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-01 07:53:02.301 17475-17475/tap30.taxi.passenger W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at java.lang.Thread.run(Thread.java:818)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider from ProcessRecord{35342aa 17475:tap30.taxi.passenger/u0a227} (pid=17475, uid=10227) requires android.permission.MANAGE_DOCUMENTS or android.permission.MANAGE_DOCUMENTS
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at android.os.Parcel.readException(Parcel.java:1620)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at android.os.Parcel.readException(Parcel.java:1573)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:3550)
05-01 07:53:02.302 17475-17475/tap30.taxi.passenger W/System.err: at android.app.ActivityThread.acquireProvider(ActivityThread.java:4783)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2018)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1468)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1088)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:942)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: at android.content.ContentResolver.openInputStream(ContentResolver.java:662)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:201)
05-01 07:53:02.303 17475-17475/tap30.taxi.passenger W/System.err: ... 8 more
I am using this library to crop an image selected from the phone album. If the image is large and crop the image, it takes some time to crop and it does that on the main UI thread because of that I am not able to show a progress dialog. The progress dialog becomes visible only after the cropping has been done which is better than having a progress dialog. So I tried putting the code inside an Async Task and when I ran, it gave an error that the cropping function has to run on UI thread. Is there any way to solve this?
Awesome library. I have an extra question:
Is there a way to scale&move the original picture instead of the cropper?
I might be doing something wrong but even though I use cropImageView.rotateImage(90);
it is not shown as rotated. Basically all I do in onCreate is:
cropImageView.setImageUriAsync(picUri);
cropImageView.rotateImage(90);
and then take care of saving the cropped picture. Am I missing something?
I'm getting some reports of user's that are unable to set a photo, and have this log message:
Fatal Exception: java.lang.RuntimeException: Failed to load sampled bitmap at com.theartofdev.edmodo.cropper.BitmapUtils.decodeSampledBitmapRegion(BitmapUtils.java:178) at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:191) at com.theartofdev.edmodo.cropper.CropImageView.getCroppedImage(CropImageView.java:456) at com.rogertalk.roger.ui.screens.ImageCropActivity.cropImagePressed(ImageCropActivity.kt:99) at com.rogertalk.roger.ui.screens.ImageCropActivity.access$cropImagePressed(ImageCropActivity.kt:28) at com.rogertalk.roger.ui.screens.ImageCropActivity$setupUI$1.onClick(ImageCropActivity.kt:74) at android.view.View.performClick(View.java:4856) at android.view.View$PerformClick.run(View.java:19956) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:211) at android.app.ActivityThread.main(ActivityThread.java:5373) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) Caused by java.io.IOException: Image failed to decode using JPEG decoder at android.graphics.BitmapRegionDecoder.nativeNewInstance(BitmapRegionDecoder.java) at android.graphics.BitmapRegionDecoder.newInstance(BitmapRegionDecoder.java:124) at com.theartofdev.edmodo.cropper.BitmapUtils.decodeSampledBitmapRegion(BitmapUtils.java:172) at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:191) at com.theartofdev.edmodo.cropper.CropImageView.getCroppedImage(CropImageView.java:456) at com.rogertalk.roger.ui.screens.ImageCropActivity.cropImagePressed(ImageCropActivity.kt:99) at com.rogertalk.roger.ui.screens.ImageCropActivity.access$cropImagePressed(ImageCropActivity.kt:28) at com.rogertalk.roger.ui.screens.ImageCropActivity$setupUI$1.onClick(ImageCropActivity.kt:74) at android.view.View.performClick(View.java:4856) at android.view.View$PerformClick.run(View.java:19956) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:211) at android.app.ActivityThread.main(ActivityThread.java:5373) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
It is happening on Android 5.0 and 5.1.1 so far. I myself cannot reproduce it, but know that this is making the app crash for those specific users. Any idea on what might be wrong?
The image uri comes null for nexus 4 and nexus 5 after clicking a picture.
Reason : getPickImageResultUri(Intent data) is returning null.
The intent doesn't have MediaStore.ACTION_IMAGE_CAPTURE, so the isCamera becomes false. also the intent in not null
Hi, is there a way to set an initial crop rectangle, for example set at 100% of the image?
Thanks
CropImageView.getCroppedImage(int reqWidth, int reqHeight) doesn't return a Bitmap of required dimensions.
I hope this issue isn't overlooked like the one with getActualCropRect() being not really "actual".
I;m currently testing and the size restrictions ahve no effect. user is able to clip image with his finger but it is not possible to impose any restriction with these width/height parameters of the getCroppedImage function. even if set to 500x500 I get result bitmaps much larger. also there is now way to set the ratio (hardcode it) of the clipping rectangle.
Hello i just implement , but thi is Cannot set Image from Camera on Nexus 5. how to fix it ?
This is a very helpful library, but I'm facing an issue right now. When I take a portrait picture using camera on Samsung S4(Android 5.0.1), the image shown on CropImageView is displayed in landscape mode. I tried fixing image orientation based on ExifInfo, but it doesn't work; It seems like pictures taken by Samsung doesn't have any ExifInfo. In my previous apps, I fix Image orientation issue by using Picasso library. Not sure how to fix it in your library.
Could you help me? Thanks a lot!
When I get a photo from G+ Photos app, sometimes this need to be downloaded. In this case the app will hang for some time and I get an ANR.
With older devices, decodeBitmat takes too long too.
I think that setImageUri needs to be executed on a background thread. The method setImageUri can accept a callback and return after the job has done.
Hi,
this doesn't work (compile 'com.theartofdev.edmodo:android-image-cropper:1.2.3') despite your page on Github saying 1.2.3 is the latest version
Would it be possible to disclose what is the latest version? My internet connection went down and I couldn't develop anymore since Gradle was trying to resolve the latest version and couldn't connect to the internet.
By the way, congratulations on this fantastic API! I love it :)
Bruno
Hello, I have been getting an error/crash using the library
Crash is :
pickImageResult.jpeg: open failed: ENOENT (No such file or directory)
and is caused in the following lines:
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:156)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
Is there a solution for this? I am using : compile 'com.theartofdev.edmodo:android-image-cropper:1.0.3'
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gmspartnersltd.earthmiles/com.gmspartnersltd.earthmiles.views.ActivityImageCrop}: java.lang.RuntimeException: Failed to load sampled bitmap
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3149)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.RuntimeException: Failed to load sampled bitmap
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:156)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
... 10 more
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.gmspartnersltd.earthmiles/cache/pickImageResult.jpeg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
... 15 more
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 19 more
java.lang.RuntimeException: Failed to load sampled bitmap
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:156)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.gmspartnersltd.earthmiles/cache/pickImageResult.jpeg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
... 15 more
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 19 more
java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.gmspartnersltd.earthmiles/cache/pickImageResult.jpeg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 19 more
android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4033)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1720)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at io.realm.internal.UncheckedRow.nativeGetString(Native Method)
at io.realm.internal.UncheckedRow.getString(UncheckedRow.java:169)
at io.realm.RewardRealmProxy.getCategory(RewardRealmProxy.java:398)
at com.gmspartnersltd.earthmiles.globalstate.App.getRewardsByCategory(App.java:2227)
at com.gmspartnersltd.earthmiles.views.mainthreetabs.rewardsfragment.RewardsSubFragment.getNewPojoListToFill(RewardsSubFragment.java:127)
at com.gmspartnersltd.earthmiles.views.mainthreetabs.BaseListFragment.onPostNetworkRequestWithCode(BaseListFragment.java:363)
at com.gmspartnersltd.earthmiles.views.mainthreetabs.rewardsfragment.RewardsSubFragment.onResume(RewardsSubFragment.java:171)
at android.app.Fragment.performResume(Fragment.java:2162)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:943)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1064)
at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1894)
at android.app.Fragment.performResume(Fragment.java:2168)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:943)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1064)
at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1894)
at android.app.Activity.performResume(Activity.java:6636)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3991)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:943)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1064)
at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:156)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
Caused by: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.gmspartnersltd.earthmiles/cache/pickImageResult.jpeg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
... 15 more
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 19 more
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
... 19 more
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:693)
at com.theartofdev.edmodo.cropper.util.ImageViewUtil.decodeSampledBitmap(ImageViewUtil.java:137)
at com.theartofdev.edmodo.cropper.CropImageView.setImageUri(CropImageView.java:290)
at com.gmspartnersltd.earthmiles.views.ActivityImageCrop.onCreate(ActivityImageCrop.java:51)
at android.app.Activity.performCreate(Activity.java:6550)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
at android.app.ActivityThread.access$1000(ActivityThread.java:197)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6872)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:442)
Hi,
in my app, i use your awesome library in a way like whatsapp, showing the image to crop and a text input below.
When i change the crop area and then i tap on the edittext, the keyboard appearance make a crop area reset.
I configured the androidManifest.xml like this for this activity
<activity ... android:configChanges="orientation|screenSize" android:windowSoftInputMode="adjustPan" > </activity>
and the layout xml is this one:
`
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center" >
<com.theartofdev.edmodo.cropper.CropImageView
android:id="@+id/imgPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
app:cropGuidelines="on"
app:cropInitialCropWindowPaddingRatio="0"
app:cropScaleType="fitCenter" />
<ImageButton
android:id="@+id/btnRotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:background="#424242"
android:padding="4dp"
android:src="@drawable/ic_action_rotate_right" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
...
`
Is there a way to keep the crop area? I have to change something on the activity configuration?
Thank you a lot for your efforts!
When the cropping window is a circle, I would like to save just the visible portion of the image (i.e. a circular cropped image). How could I do that?
There are any posibility to do backwards compatible with API 9? Tranks¡
Hello,
we had a problem that on old memory limited devices we did not get a reasonable quality of cropped images (because we would have to limit the output size significantly to not have out of memory issues when the app is limited to 16MB ram) - so we decided the best option is to simply use the view to let the user choose a crop / rotation area and let the server do the heavy lifting. The only thing missing for this to work would be an accessor for mDegreesRotated
. Seems like an easy improvement :)
thanks for keeping this view alive :)
regards,
Herbert
Hello!
Sorry for my English.
I set the aspect ratio of 1: 1 (square), and the width and height of the cropped images are different. It turns out that in the end we did not square.
How can I solve this problem?
cropImageView = (CropImageView) findViewById(R.id.cropImageView);
cropImageView.setImageUriAsync(imageUri);
cropImageView.setAspectRatio(1, 1);
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(CropImageView.Guidelines.ON);
cropImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
...
Rect rect = cropImageView.getActualCropRect();
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect: " + rect);
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect.left: " + rect.left);
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect.top: " + rect.top);
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect.right: " + rect.right);
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect.bottom: " + rect.bottom);
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect.width: " + rect.width());
Log.i(Const.Debug.DEBUG_TAG, "Actual crop rect.height: " + rect.height());Actual crop rect: Rect(450, 0 - 2685, 2234)
Actual crop rect.left: 450
Actual crop rect.top: 0
Actual crop rect.right: 2685
Actual crop rect.bottom: 2234
Actual crop rect.width: 2235
Actual crop rect.height: 2234
....
Actual crop rect: Rect(226, 1161 - 2461, 3395)
Actual crop rect.left: 226
Actual crop rect.top: 1161
Actual crop rect.right: 2461
Actual crop rect.bottom: 3395
Actual crop rect.width: 2235
Actual crop rect.height: 2234
If I put setShowCropOverlay(false) in my Activity onCreate(), the crop overlay is hidden, but doing setShowCropOverlay(true) later does not do anything.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.