igreenwood / simplecropview Goto Github PK
View Code? Open in Web Editor NEWA simple image cropping library for Android.
License: MIT License
A simple image cropping library for Android.
License: MIT License
Never mind - user error.
Error:(42, 9) Attribute application@allowBackup value=(false) from AndroidManifest.xml:42:9 is also present at com.isseiaoki:simplecropview:1.0.7:12:9 value=(true) Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:41:5 to override
libraries should not set the allowBackup attribute
The SimpleCropView is very slow on Android 5.1.1.
I tested it on others and it looks great, but in Android 5.1.1 is too slow
Message: skip frames, much work on main thread
Response: The image was too big.
Hello,
I am getting this exception:
java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
at android.graphics.Bitmap.createBitmap(Bitmap.java:698)
at com.isseiaoki.simplecropview.CropImageView.getCroppedBitmap(SourceFile:1012)
at bci.onClick(SourceFile:1064)
at android.view.View.performClick(View.java:4463)
at android.view.View$PerformClick.run(View.java:18801)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
every once in a while. Any idea on what's happening there?
Cheers,
Sakis
It would be nice to be able to specify the shape of the crop selector to be a circle or rectangle instead of just a rectangle.
Currently when you crop a photo all the exif data from the original photo gets nuked. There should be a way to keep the exif data from the original photo so the gps data and time stamp dont get deleted
How can get path of cropped Bitmap file?
How to solve it?
Firstly, fantastic library, I like the way it looks, how easy is to implement and use it.
I only have one issue and I don't know to what it is related: when I am working with a portrait image, there are performance issues with dragging the rectangle or resizing it. This does not happen when using a landscape picture, even if the landscape picture's size is bigger.
I would like to have the frame be the full size of the image initially, or even some custom size and position.
Hey,
I ran into an issue when setting output sizes. The resizing seems to derive an aspect ratio from getRatioX()
and getRatioY()
, which, in the typical use case, results in an image of size 1:1. What would be much more expected would be to resize the cropped selection and maintain that aspect ratio rather than overwrite/ignore it.
This change would be very simple. You would just need to change some code in CropImageView.java
in the method scaleBitmapIfNeeded(Bitmap)
. The only line that needs changing would be this:
float imageRatio = getRatioX() / getRatioY();
to
float imageRatio = (float) width / (float) height;
(Maybe change the var name to croppedRatio?)
I've currently copied the class locally and replaced this line and have it functioning correctly. However, I would love to get this in the library. I don't mind making a PR. Let me know ^_^
Russell
Sometimes, You want to crop an large picture, it may be 8000x6000, And then, App use a Loader such as picasso to display a thumbnail image to the ImageView to prevent OutOfMemory crash. Maybe, a 400x300 picture to displayed in the ImageView. Then cropping of the image is not cropping to the original image, in other words, it cannot get a cropped image to original picture..
there is something wrong with setImageUrl.
like the title says , i use the crop tool and it always crops the middle part of the frame regardless of position
Hi. Can I get cropped region coordinates?
When I select certain photos overlay drawing is lacking a line in top and/or bottom. Here's a screenshot of what is happening:
As you can see in the screenshot above, the top line of overlay is not getting drawn.
Here is how I am using CropImageView
<com.isseiaoki.simplecropview.CropImageView
android:id="@+id/cropImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
custom:scv_crop_mode="free"
custom:scv_guide_color="@color/accentColor"
custom:scv_handle_color="@color/accentColor"
custom:scv_frame_color="@color/accentColor"
custom:scv_background_color="@color/solidBlack"
custom:scv_handle_size="8dp"
custom:scv_touch_padding="10dp" />
Let me know if you need more info.
I can also email you the original photo which caused this.
When trying to load a camera image from my Galaxy s6, the app force closes.
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:527)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:599)
at android.provider.MediaStore$Images$Media.getBitmap(MediaStore.java:724)
at com.shifat.cropandupload.MainActivity.onActivityResult(MainActivity.java:66)
at android.app.Activity.dispatchActivityResult(Activity.java:5192)
When I load a picture which the size is more than 3M,I will take a lot of time to get the onSaveCallback of the cropview!!!
i would like to contribute here @IsseiAoki ?
Is there any way to rotate the image??
As a developer, i want to set/change during run-time the crop boundaries (currently i can only get the actual crop rectangle but not set it)
I can able to crop image in emulator but can not do it in real device of api 19 . can anyone please help me with this issue?
` if (requestCode == REQUEST_CHOOSE_FILE) {
Uri imageUri = data.getData();
// filename= data.getData().getLastPathSegment();
filename= data.getData().getPath();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
Intent i=new Intent(MyProfileActivity.this,SetImage.class);
i.putExtra("Bitmap",bitmap);
startActivity(i);
profilePic.setImageBitmap(bitmap);
save.setVisibility(View.VISIBLE);
} catch (IOException e) {
e.printStackTrace();
}
}`
This is my code and I can not go to setImage activity which has code for cropping the image in phone.
Code of setImage activity is here:
` @OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_image);
cancelbutton = (Button) findViewById(R.id.btnCancel);
ok = (Button) findViewById(R.id.btnOk);
crop=(Button)findViewById(R.id.btnCrop);
croppedImageView = (ImageView) findViewById(R.id.croppedimageView);
image = (CropImageView) findViewById(R.id.imageView);
image.setCropMode(CropImageView.CropMode.RATIO_1_1);
image.setMinFrameSizeInDp(100);
image.setBackgroundColor(0xFFFFFFFB);
image.setOverlayColor(0xAA1C1C1C);
image.setFrameColor(getResources().getColor(R.color.primary));
image.setHandleColor(getResources().getColor(R.color.white));
image.setGuideColor(getResources().getColor(R.color.white));
cancelbutton.setOnClickListener(this);
ok.setOnClickListener(this);
crop.setOnClickListener(this);
String imagePath = getIntent().getStringExtra("imagePath");
Bitmap bitmap = (Bitmap) getIntent().getParcelableExtra("Bitmap");
image.setImageBitmap(bitmap);
}`
Hi,
I got this error message whenever I'm trying to crop 1200 x 1200px (or its multiply 2400 x 2400 etc) image.
java.lang.IllegalArgumentException: y + height must be <= bitmap.height()
at android.graphics.Bitmap.createBitmap(Bitmap.java:669)
at com.isseiaoki.simplecropview.CropImageView.getCroppedBitmap(CropImageView.java:1012)
I called getCroppedBitmap() without resize the image (moving the handle)
I'm using:
cropMode="ratio_1_1"
handleSize="12dp"
minFrameSize="200dp"
initialFrameScale="1.0"
Can you help me? Thank you
always crop center image and not selected area.
java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
at com.isseiaoki.simplecropview.CropImageView.getBitmap(CropImageView.java:924)
at com.isseiaoki.simplecropview.CropImageView.setImageResource(CropImageView.java:964)
It would be nice to have a "whole in one"-lib. :-)
Hi,
We are getting an error like :
java.lang.RuntimeException: Unable to start activity ComponentInfo{....CropImageActivity}: java.lang.RuntimeException: Parcel android.os.Parcel@41b317a0: Unmarshalling unknown type code 51 at offset 400
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2279)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.access$800(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:814)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@41b317a0: Unmarshalling unknown type code 51 at offset 400
at android.os.Parcel.readValue(Parcel.java:2092)
at android.os.Parcel.readSparseArrayInternal(Parcel.java:2396)
at android.os.Parcel.readSparseArray(Parcel.java:1747)
at android.os.Parcel.readValue(Parcel.java:2082)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2329)
at android.os.Bundle.unparcel(Bundle.java:249)
at android.os.Bundle.getSparseParcelableArray(Bundle.java:1273)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1745)
at android.app.Activity.onRestoreInstanceState(Activity.java:944)
at android.app.Activity.performRestoreInstanceState(Activity.java:916)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1138)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.access$800(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:814)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)
at dalvik.system.NativeStart.main(Native Method)
Can you help me?
Thanks
SimpleCropView is Very nice and good !
Why there is no rotating function
like
https://github.com/edmodo/cropper ’s
cropImageView.rotateImage(ROTATE_NINETY_DEGREES);
simetimes this is It is necessary.
Very nice and clean library!
I was trying to use it with Picasso. Images load just fine, they show up, but without cropping frame. Also, trying to rotate CropView with the new rotation method causes crash:
Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference at com.isseiaoki.simplecropview.CropImageView.rotateImage(CropImageView.java:972)
The actual reason is that Picasso uses PicassoDrawable
internally to load images into ImageViews. And SimpleCropView
doesn't have corresponding method overloaded. As a workaround, I use callback to get bitmap and set it directly to CropView. But it would be nice if it worked out of box.
I cannot crop image When I setImageURI from image in storage for cropImageView. When, I try setImageBitMap from image in drawable, It's works fine.
Error:Execution failed for task ':app:processDevDebugManifest'.
Manifest merger failed : Attribute application@label value=(@string/XYZ) from AndroidManifest.xml:74:9-40
is also present at [com.isseiaoki:simplecropview:1.0.13] AndroidManifest.xml:11:18-50 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:71:5-374:19 to override.
public static int getExifOrientation(Context context, Uri uri) {
String authority = uri.getAuthority().toLowerCase();
int orientation;
if (authority.endsWith("media")) {
orientation = getExifRotation(context, uri);
} else {
orientation = getExifRotation(getFileFromUri(context, uri));
}
return orientation;
}
uri.getAuthority() == null will cause NullPointException. For example: Uri "/storage/emulated/0/homerun/homerun-Pictures/IMG_20160615_075035.jpg"
Consider this case. I enable crop using setCropEnabled(true)
and adjust crop frame. Then I disable crop using setCropEnabled(false)
. Now if I call startCrop()
I suppose it should ignore the previously set crop frame, but it will crop according to the frame which was set when crop was enabled.
I think calcCropRect()
should take the value of mIsCropEnabled into account. Or at least there should be a public method to reset crop frame.
Sorry if I am buzzing you with a lot of issues. Thank you for taking the time to check these out.
how to custom the handleSize, it's too large!
When I add an image that was taken in portrait and set it as the image to crop it show up like this - http://s14.postimg.org/yan77l19d/Screenshot_2016_01_24_00_31_28.png.
Even using rotateImage won't fix the problem.
What is causing it?
After cropping the first image, other attempt to crop other images return the first image cropped, until the app is restarted.
HI,
This is what I am trying to do, I want to let user cropped the image with the Circle at the same time I want to send to Square version to the sever.
It would be helpful to set min size of final cropped bitmap in pixels.
If i set image uri with .setImageURI method the crop doesn't work
I just want to fit the image cropping frame to fit the device width or Image width and height accordingly to maintain aspect ratio. I want to make it fix so that use can not resize it just can drag it to select desire portion of the image.
If I use setEnabled(false); then it also stops dragging feature. I want to provide the user to select the portion of the image to crop but don't want to resize the cropping area (disable resize using 4 dots at the corner of grid)
So how can I achieve this? Can you please provide this feature also. Also the modes like fit to width (height should be as it is to maintain aspect ration) same way fit to height and so on....
in getRatioX() and getRatioY(), FREE mode is not taken into account. So in scaleBitmapIfNeeded(Bitmap) the value of imageRatio will always be 1.0 in FREE mode, which results in a loss of aspect ratio in scaled bitmap.
I have your older version of the library and those did not have the mCropView.startCrop
and mCropView.startLoad
methods. Also i developed it around where I pass the absolute path to the file and load it in the CropImageView bitmap
.
Since you have introduced the uri
model, is it mandatory to use this?
Its going be quite tough to convert all the logic to uri based.
is there any jar version for this library? because of some limitation I unable to use gradle in my projects, thanks
Hi guys. You are made awesome widget. But it has one critical bug. When set widget's width or height to
match_parent
it became laggy. Looks like something going wrong on measure or on layout stage or something else running into the loop.
GPU monitor http://screencloud.net/v/xc3i
Memory monitor http://screencloud.net/v/1Y8k (leaking memory)
I have only one activity withSimpleCropView
width and height arematch_parent
.
Sorry, my mistake. I loaded 8 megapixels bitmap into view directly.
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.