Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to crop for large images

My application needs to open the gallery and pick an image to crop. I set the target size as a value(87%*screenWide). Now, problems occur. In large screen devices, the gallery failed to return the cropped image and the log said "!!! FAILED BINDER TRANSACTION !!!". In most of the devices, it is OK.

Can any one help me for this? Thanks!

I use Intent.ACTION_GET_CONTENT to crop, and set the outputX, outputY etc. It's routine to crop images.

like image 348
Henry Sou Avatar asked Dec 09 '22 12:12

Henry Sou


2 Answers

I ran into a similar problem. If you're using Android's default cropping tool, it has a 256x256 max crop size limitation. Set the size of your crop to smaller or equal to that and you'll be fine.

intent.putExtra("outputX", 256);
intent.putExtra("outputY", 256);
like image 59
colinwong Avatar answered Dec 31 '22 14:12

colinwong


Try sending the intent as below:

mSavedUri = Uri.fromFile(new File("/sdcard/cropped.jpg"));

mImageSelectIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
mImageSelectIntent.setType("image/*");
mImageSelectIntent.putExtra("crop", "true");
mImageSelectIntent.putExtra("aspectX", 4);
mImageSelectIntent.putExtra("aspectY", 3);
mImageSelectIntent.putExtra("outputX", mImageWidth);
mImageSelectIntent.putExtra("outputY", mImageHeight);
mImageSelectIntent.putExtra("output", mSavedUri);

The cropped image will be saved as a cropped JPG and not returned to you via "data".

like image 39
Arik Halperin Avatar answered Dec 31 '22 13:12

Arik Halperin