Resizing doesn't work at all
See original GitHub issueHello,
I like this cropper very much. However, the resizing feature doesn’t seem to work at all. I am using the Activity approach, like this:
CropImage.activity(sourceFile) .setActivityTitle(this.getResources().getString(R.string.CropImage)) .setAspectRatio(1, 1) .setAutoZoomEnabled(true) .setFixAspectRatio(true) .setGuidelines(CropImageView.Guidelines.OFF) .setNoOutputImage(false) .setOutputCompressQuality(70) .setOutputUri(sourceFile) .setRequestedSize(512, 512) .start(this);
The image comes from the camera and should be then cropped by user. The resulting image, no matter what, should be 512x512px, whether the user selected larger or smaller region from the image, than those dimensions. However, I am still getting only the cropped region in its original size, instead of 512x512.
In the code above, “sourceFile” is an Uri pointing to local filesystem, and at that Uri, picture taken from camera already exists. I would like to crop and resize it in-place if possible (replacing the original large image).
By debugging the code of this library, I found out that in class CropImageView, method startCropWorkerTask, resizing is only performed if mLoadedSampleSize > 1. But for my case, mLoadedSampleSize is always 1. I don’t understand the meaning of this variable and even when I commented the condition out, I still got image of size 847x847, not 512x512.
Please can you advice what should I do, or is this a bug?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
@princekhan2 your problem is not related to this issue. This one has been already solved and closed, please file a new issue for your problem.
Hi sir i am new to programming . Your croper image so nice and good . But in my case it does not work compile ‘com.theartofdev.edmodo:android-image-cropper:2.3.+’ And I added the activity in the manifest .
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity" android:theme="@style/Base.Theme.AppCompat"/> Java code
photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
//Intent imageDownload = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
Intent imageDownload=new Intent(); imageDownload.setAction(Intent.ACTION_GET_CONTENT); imageDownload.setType(“image/*”); startActivityForResult(imageDownload, GALLERY_REQUEST_CODE); }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode==GALLERY_REQUEST_CODE && requestCode==RESULT_OK) { Uri imageUri=data.getData(); CropImage.activity(imageUri) .setGuidelines(CropImageView.Guidelines.ON) .start(this); } if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) { CropImage.ActivityResult result = CropImage.getActivityResult(data); if (resultCode == RESULT_OK) { Uri resultUri = result.getUri(); m.setImageURI(resultUri); } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) { Exception error = result.getError(); } } I am using android studio 2.2.1. And android version lollipop 21.