Android-Image-Cropper
Android-Image-Cropper copied to clipboard
java.lang.IllegalArgumentException: width/height must be > 0
On some device, when I do
Bitmap bitmap = cropImageView.getCroppedImage()
Then It makes illegalargumentexception like
java.lang.RuntimeException: Failed to load sampled bitmap: content://media/external/images/media/31373 width must be > 0 at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:218) at com.theartofdev.edmodo.cropper.CropImageView.getCroppedImage(CropImageView.java:566) at com.theartofdev.edmodo.cropper.CropImageView.getCroppedImage(CropImageView.java:544) at com.petabyte.composewatch.Activity.CropActivity.onOptionsItemSelected(CropActivity.java:71) at android.app.Activity.onMenuItemSelected(Activity.java:3205) at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:421) at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:188) at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:103) at android.support.v7.app.AppCompatDelegateImplV7.onMenuItemSelected(AppCompatDelegateImplV7.java:663) at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:810) at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:957) at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:947) at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:618) at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:155) at android.view.View.performClick(View.java:5698) at android.widget.TextView.performClick(TextView.java:10855) at android.view.View$PerformClick.run(View.java:22565) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7230) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.IllegalArgumentException: width must be > 0 at android.graphics.Bitmap.checkWidthHeight(Bitmap.java:443) at android.graphics.Bitmap.createBitmap(Bitmap.java:822) at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:158) at com.theartofdev.edmodo.cropper.BitmapUtils.cropBitmap(BitmapUtils.java:214)
Do you know why it occur?
That is strange... need more data: Do you use the latest version? looks like you do but I want to make sure. Do you use fixed aspect ratio? if so what is it? Can you reproduce it or you see it from production? Do you know on which devices it happens?
Yeah, I use latest version.
and I used fixed aspect to
getWindowManager().getDefaultDisplay().getWidth(), getWindowManager().getDefaultDisplay().getHeight()
And it worked perfect when I used cropimageactivity.
I used CropImageActivity before, but I want to rotate aspectradio instead of the picture. So I made my on Activity with CropImageView
I don't know how it can happen :disappointed: Don't even know what to tell you... you can try the latest version and debug to find more clues...
Well... if it happens again or someone else has this issue please reopen it.
I get the same error or the wrong area cropped. I have a repro and cause identified here: https://github.com/edmodo/cropper/issues/134
@ArthurHub This is happen when use negetive rotation and call getCroppedImage after it. using negative rotation corrupts rotate rectangle.
Any updates on this issue?
Hello there @ArthurHub I'm facing the same issue but my project is on OpenCV with kotlin see below
the line complaining is 47