Cropping an image on iPhone reduces image size

I need to crop a photo from the gallery of an Android phone and then edit it. The original size of the photo is 3264 * 2448, which is displayed on my screen with a size of 1280 * 720 as a thumbnail. When I crop it, I get a 185 * 139 image.

The code I use to trim,

Intent cropIntent = new Intent("com.android.camera.action.CROP"); cropIntent.setDataAndType(picUri, "image/*"); cropIntent.putExtra("crop", "true"); cropIntent.putExtra("return-data", true); startActivityForResult(cropIntent, PIC_CROP); 

When I display a cropped image in an imageView, it displays as a much smaller image.

I have to crop the original image, not the smaller version. Can any of you explain to me how to do this?

+6
source share
3 answers

Please try this, I know it too late, but it can help someone.

 private void performCrop() { try { //call the standard crop action intent (the user device may not support it) Intent cropIntent = new Intent("com.android.camera.action.CROP"); //indicate image type and Uri cropIntent.setDataAndType(mImageCaptureUri, "image/*"); //set crop properties cropIntent.putExtra("crop", "true"); //indicate aspect of desired crop cropIntent.putExtra("aspectX", 4); cropIntent.putExtra("aspectY", 3); //indicate output X and Y cropIntent.putExtra("outputX", 800); cropIntent.putExtra("outputY", 800); File f = new File(Environment.getExternalStorageDirectory(), "/temporary_holder.jpg"); try { f.createNewFile(); } catch (IOException ex) { Log.e("io", ex.getMessage()); } uri = Uri.fromFile(f); cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(cropIntent, PIC_CROP); } //respond to users whose devices do not support the crop action catch (ActivityNotFoundException anfe) { //display an error message String errorMessage = "Your device doesn't support the crop action!"; Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); toast.show(); } } 

Make your onActivityResult as follows: -

  @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PIC_CROP) { String filePath = Environment.getExternalStorageDirectory() + "/temporary_holder.jpg"; thumbnail = BitmapFactory.decodeFile(filePath); //thumbnail = BitmapFactory.decodeFile(filePath); // Log.i("",String.valueOf(thumbnail.getHeight())); ImageView image = (ImageView) findViewById(R.id.pestImage); image.setImageBitmap(thumbnail); } } 
+12
source

Add

 intent.putExtra(MediaStore.EXTRA_OUTPUT, tempUri); 

Then you can get an image file that will not be reduced. And use this saved file instead:

 Intent.getExtras().getParcelable("data") 

Just ignore the returned bitmap.

+2
source

First, you should be aware that the intent of cropping cannot be relied on for compatibility between devices. (Any OEM can replace the camera / gallery app with its own version). As an aside, I think you are missing a few additional features that should go on target and give you the desired effect.

 // width & height are your desired width/height for the cropped result cropIntent.putExtra("outputX", width); cropIntent.putExtra("outputY", height); cropIntent.putExtra("aspectX", width); cropIntent.putExtra("aspectY", height); cropIntent.putExtra("scaleUpIfNeeded", true); 

Try adding them to your intention and see how it turns out.

0
source

All Articles