jdamcd / android-crop Goto Github PK
View Code? Open in Web Editor NEWAndroid library project for cropping images
Android library project for cropping images
As a work-around, hardware acceleration can be disabled for CropImageActivity
in the manifest. However, it should be possible to fix this with some changes to the draw logic.
There is an issue with the library that if the user gets to the cropping screen, and flips his device - the received image clears and the user can't crop it.
when i want to cut a larger picture,sometimes will be crashes and move highlightView to slow. So i think we import picture when we need to compress.
setupFromIntent
In Google Play I have the following stack trace
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.krittiq.app/com.soundcloud.android.crop.CropImageActivity}: java.lang.IllegalArgumentException: Unknown column requested: _data
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
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:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Unknown column requested: _data
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:413)
at android.content.ContentResolver.query(ContentResolver.java:461)
at android.content.ContentResolver.query(ContentResolver.java:404)
at com.soundcloud.android.crop.CropUtil.getFromMediaUri(CropUtil.java:95)
at com.soundcloud.android.crop.CropImageActivity.setupFromIntent(CropImageActivity.java:126)
at com.soundcloud.android.crop.CropImageActivity.onCreate(CropImageActivity.java:79)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
... 12 more
Device: n7000 (Android 4.4)
I seem to be having permission problems pulling images from the "Recent" images, with it complaining about android.permission.MANAGE_DOCUMENTS missing, even though I have it declared.
Height should match new toolbar height for Lollipop.
As said in title, when a user flips the orientation of their device, the image is not loaded. When "done" is pressed, no usable information returned.
Using this call from an Activity:
new Crop(selectedImageUri).output(croppedFileUri).withAspect(width, height).withMaxSize(width, height).start(this);
I currently develop an app for Android 4+.
However, because that app is using nested fragments (4.1+) I had to use the compatiblity library.
I badly need a start method that would work with the support Fragment class.
First,this issue still exists it seems
#27
so,I made the following changes in CropImageActivity.java:
Android-crop is very good library.
There is issue on CropImageActivity at line 131
is = getContentResolver().openInputStream(sourceUri);
I get exception occasionally when selecting image.
I have an image that I need cropped. However, it has and ID or Tag associated with it. How can I open the CropImageActivity and pass it the ID and then in the callback in the main Activity access that ID?
I tried playing around with the Extras
, but gave up after a while. Am I missing something basic about Android? I understand how to pass and receive objects vi an Intent
but can we also "pass through"?
Also while trying to start the crop activity manually instead of by new Crop(sourceUri)
, I ran into problems because the Interface Crop. Extra
is not public. Can that be made public?
HI, I 'm using this library and it is working very well, i've aa question
is it possible to fix the dimension of image cropping window with fix resolution 1980x1080?
Thanks jdamcd for the source.
there is an issue like the followed:
After choose picture, this happened in reading picture at CropImageActivity at line number : 135. the code is
rotateBitmap = new RotateBitmap(BitmapFactory.decodeStream(is, null, option), exifRotation);
When I fire up the crop activity, the initial crop area is square and typically smaller than the image. For my use cases its most common to do no cropping, so I'm thinking if the crop area was the full image to start then that would work best for users.
I'm invoking it like this:
Uri outputUri = Uri.fromFile(new File(Constant.SD_PICTURE_FOLDER, Constant.LOGO_NAME));
new Crop(source).output(outputUri).start(activity);
Hello!
Would you like me to Upload to google play?
First, thank you for your perfect code : )
I want to crop image to 300*300 on android 4.1.2 , and my code like this:
new Crop(inputUri).output(outputUri).withMaxSize(300, 300).asSquare().start(mActivity);
But I found it does not work.
So I rewrite some code in the library's source code.
In line:339
croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());
changed to
Options options = new BitmapFactory.Options();
options.inSampleSize = width / maxX;
if(options.inSampleSize <= 0) {
options.inSampleSize = 1;
}
croppedImage = decoder.decodeRegion(rect, options);
Finally, thanks again.
When I saw this post it looked nice but whenever I selects a picture it throws null pointer exception and application crashes.
It's not completely obvious that you can in fact scale the image. It took me several minutes before I realized I had to drag on the edges. I may just be an idiot but perhaps including the blue dots at all times or for a few seconds when the activity first launches would better suggest that to the user.
Only allowing the crop activity to be started via an activity is a bit restrictive, I'm trying to deliver my result to a fragment's onActivityResult instead of an activity and also add some extras to the intent that is returned. I know this is vague but some more control over launching the activity/returning a result would be very helpful.
This is happening in CropImageActivity.java on line 132. Any idea how can we solve this?
If the original picture is taken with a camera orientation different from default, the cropped photo is rotated (as far as I can tell, the rotation is the negative rotation of the original). I guess the EXIF info is removed or somehow messed up.
I've tested on multiple devices and it's consistent.
I'm starting to do some debugging in the source code, but I would appreciate any help understanding the logic. Thanks.
This was tested on a 2.3.3 device; easy work around is to simply make sure the output URI is different from the input URI but may be causing issues related to #46.
Relevant code is
(https://github.com/brandon515/android-crop/blob/aa6023d8cb276805ec883f3eecaec4c4949007a6/lib/src/main/java/com/soundcloud/android/crop/CropImageActivity.java#L407):
try {
outputStream = getContentResolver().openOutputStream(saveUri);
if (outputStream != null) {
croppedImage.compress(Bitmap.CompressFormat.JPEG, 90, outputStream);
}
} catch (IOException e) {
setResultException(e);
Log.e("Cannot open file: " + saveUri, e);
} finally {
CropUtil.closeSilently(outputStream);
}
if (!IN_MEMORY_CROP) {
// In-memory crop negates the rotation
CropUtil.copyExifRotation(
CropUtil.getFromMediaUri(getContentResolver(), sourceUri),
CropUtil.getFromMediaUri(getContentResolver(), saveUri)
);
}
I'd do the fix myself but really need an IDE for this fix and it doesn't appear to be easily importable into Eclipse (I ain't savvy with Gradle and Android Dev Tools)
Hi !
I found your lib and it's a very good work. Thank you very much.
However, i have a little problem. When my image is cropped, result picture is rotated (90 on the right).
Is a known issue or it's just me ?
Thx :p
croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());
OutOfMemoryError Exception
Now,we can see the length-width ratio is 1,but I want to know how to set the ratio is 1.5 or 2 or ...,who can help me,ths.
Trying to enforce a cropped image to be 256x256 and it doesn't resize. Is there a fix for this?
Some times the picture needs to be rotate before cropping. It would be nice to have a possibility for this in the Crop activity.
Thank you in advance!
I'm getting a blank screen (not loading image) with some images in Android 4.4.2. As fas as I know, image file exists, but it is not being loaded.
Importing the .zip 2 projects in Eclipse is a mess.
They have no target APIs, the lib is not a lib project, there are no source files, etc.
It is just built for Gradle?
Hi is possible to create a AAR of this library and upload it to maven central?
Hi,
Is there any option to remove the scaling of the box ?
Ultimetely, I want to make it scale only when i drag it from corners.
Hi,
I try to crop a taken photo but doesn't work.
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, 1);
.....
onActivityResult
Uri inputUri = data.getData();
Uri outputUri = Uri.fromFile(new File(getCacheDir(), "cropped"));
new Crop(inputUri).output(outputUri).asSquare().start(this);
The image is not loaded, why?
Thanks
The little circle "handles" on the crop box should start out visible, rather than requiring the user to drag the side before becoming visible.
This would let the user know that the box is resizable, and not just movable.
I am cropping the gallery image and getting this error-
java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaDocumentsProvider uri content://com.android.providers.media.documents/document/image%3A29879 from pid=23358, uid=10203 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission().
Using multitouch to scale the crop region seems to produce some odd results, is that because multitouch isn't really supported? Or am I just using it wrong?
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.