Open VivekKannaV opened 6 years ago
Try setting setMaxBitmapSize to something like 10000; I don't know what the number represents but it improved the quality
UCrop.Options options = new UCrop.Options();
options.setCompressionQuality(100);
options.setMaxBitmapSize(10000);
UCrop.of(imageUri, Uri.fromFile(new File(getCacheDir(),"temp.jpg")))
.withOptions(options)
.start(MainActivity.this);
@VivekKannaV Hello! Did you solve it?
I faced the same problem and found out that this was happening because(Bitmap) data.getExtras().get("data")
from onActivityResult
was referring to a thumbnail image when I was taking picture from camera.
Add the following code before start of your camera Intent. This will store the reference of the real image to imareUri
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File file = new File(Environment.getExternalStorageDirectory(), "/your_app_Name/Images" + "/photo_" + timeStamp + ".jpg");
imageUri = Uri.fromFile(file);
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(cameraIntent, IMAGE_FROM_CAMERA);
Now use the imageUri and feed it to UCrop
UCrop.of(imageUri,Uri.fromFile(new File(getCacheDir(), destinationFileName))).withOptions(options).start(YourActivity.this);
If you want to further improve the quality of the image you can do
options.setMaxBitmapSize(10000);
before starting UCrop activity.
Hope this helps
There is a more simple solution to this issue : In the openCropActivity method set - .withMaxResultSize to (1000,1000)
UCrop.of(sourceUri,` destinationUri)
.withMaxResultSize(1000, 1000)
.withAspectRatio(5f, 5f)
.start(this);
Hi all, I tried all above spoken solutions, still quality issue exits. Kindly let me know if any possible solution we have to maintain same size.
Thanks.
Hi all, I tried all above spoken solutions, still quality issue exits. Kindly let me know if any possible solution we have to maintain same size.
Thanks.
uCrop.withMaxResultSize(1000, 1000); options.setCompressionQuality(100); options.setMaxBitmapSize(10000);
use these three lines, this will improve the quality
Hi all, I tried all above spoken solutions, still quality issue exits. Kindly let me know if any possible solution we have to maintain same size. Thanks.
uCrop.withMaxResultSize(1000, 1000); options.setCompressionQuality(100); options.setMaxBitmapSize(10000);
use these three lines, this will improve the quality
This still not working when you capture the document image or Form which contain lots of text after crop the image document text is not visible clearly Try all solution which are mention above. Attach document SS after crop.
After Processing Crop & rotate, Image output quality got very poor despite of choosing lossless compression (PNG).
We'r looking to use for documents, it's look unfair to read after crop the document.
Even we didn't crop / rotate, we just pass the image into UCrop but the output has been very poor.
Kindly looking for an awesome output from you.
Note: Output file size doesn't matter upto 2MB