Open Amirhgh74 opened 7 years ago
@Amirhgh74 Yes it is possible. You can do it using the following line.
Crop.of(source, destination).withAspect(ASPECT_X, ASPECT_Y).start(context, Class/Fragment here);
You would do this in the onActivityResult. This is how I do it to get a 16:9 ratio image:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == Crop.REQUEST_PICK && resultCode == Activity.RESULT_OK) {
beginCrop(data.getData());
} else if (requestCode == Crop.REQUEST_CROP) {
handleCrop(resultCode, data);
}
}
private void beginCrop(Uri source) {
Uri destination = Uri.fromFile(new File(getActivity().getCacheDir(), "cropped"));
Crop.of(source, destination).withAspect(ASPECT_X, ASPECT_Y).start(getActivity(), RegistrationDialog.this);
}
If you look at the source code for the class Crop, you'll see the default aspect ratio is 1:1 but that there are a couple methods where you can set your own aspect ration.
i want to have crop ratio to be fixed but not something like square , is it possible that i set the ratio to be cropped ?