in my app I capture a photo using intent MediaStore.ACTION_IMAGE_CAPTURE and I save image into external storage that is private to my app. I also save the path to taken picture.
In next step I would like to crop 3 pictures from this photo but I cannot figure out how to do it. I found this article Crop an Image by passing the image file path in Android but the answer uses com.android.camera.action.CROP, which is often not supported. I would like to crop it like this
Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.xyz);
resizedbitmap1=Bitmap.createBitmap(bmp, 0,0,yourwidth, yourheight);
but I need to crop picture according to user selection. Can anyone help me with this? I am pretty stuck here.
So I ended up using some third party library for cropping pictures. I recommend you to do the same. You will find plenty of them on github, choose according to your preferences.
Related
I need to pick an image from the gallery of the phone in order to do some stuff with that.
For this purpose I tried to follow what is inside this android pick images from gallery thread but I think it's too old, probably I need to use the intent anyway but I don't understand how and how to pass the image picked to a bitmap variable.
Precisely I need to take an image and then convert it to bitmap and do other stuff (ml algorithms).
Thanks.
my requirement is to crop image with fixed size in android.. I am getting image from gallery or camera and now want to show fixed size of crop option on that image so that user just drag the rectangle box and set anywhere on the image and save.
Please google your question before asking them on StackOverflow...
There are plenty of libraries which are doing what you want. I use this one which is stable, clear and easy to use but you'll find plenty of others just by looking on Github with a search like this.
For the fixed size, there is maybe an option directly implemented in the API of the library I proposed you (never had this requirement), but if not, you just have to change the draw method of the transparent rectangle.
I am making an application where I need to take a photo and then crop a 100x100 area from it. Right now I am making an intent call for taking a picture and then I create a CropActivity that will crop it.
I was wondering if default photo application could be set crop taken picture and show a border on screen to identify an area which is supposed to be cropped before taking the picture.
Maybe with some extras? I dont know. I search ong enought, but didnt find anything to do this in one step WITH preview.
(please do not post solutions, how to crop image separately and without a preview, I already know)
I was wondering if default photo application could be set crop taken picture and show a border on screen to identify an area which is supposed to be cropped
There are well over 1 billion Android devices, spread across over a thousand device models. Those have hundreds of "default photo applications", as a mix of pre-installed apps and other camera apps that users installed and made be their default.
None have to support any sort of crop-related extras.
You can save path of image(i.e. Uri) in a string then putExtra this with your intent as:
String mUri = "android.media.whatever";
Intent mIntent.putExtra("imgUri", mUri);
and then in receiver side you can get the image using:
Bitmap img = BitmapFactory.decodeFile(getIntent().getStringExtra("imgUri");
i am doing an android app that launches camera and capture an image, then crop and save the image. Then takes the image for some process.
i was trying with some suggestions and tutorials by searching on Google. but i am getting error after cropping. The image is being cropped and actual image remains in SD-Card also the cropped image saved as "image~2" in same location. but while we try to use the cropped image filenotfoundException is returned. Any one please help me.
"can i post my code?" - You should, actually, if you want some help here... Anyway considering the exception, you're searching for the image where it is not.
Or you can try this: https://github.com/edmodo/cropper
I capture Image in my camera application (in app camera) and save it to the file system. In file system, it shows me all the meta details like resolution, ISO, Aperture, Date, rotation etc. when I press "Details" button.
But when I crop the same image i lost all this meta information. How can preserver this information in cropped version too.
I haven't tried this class personally but it looks like it will do what you need.
http://developer.android.com/reference/android/media/ExifInterface.html
You'll need to get all the attributes you want from the original image file, and save them on your cropped copy. Good luck!