# Android裁剪图片最简单方法

**URL:** <https://www.isharkfly.com/t/android/2191>\
**Category:** 程序语言\
**Created:** [November 29, 2012, 1:11am UTC](https://www.isharkfly.com/t/android/2191 "2012-11-29T01:11:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [November 29, 2012, 1:11am UTC](https://www.isharkfly.com/t/android/2191/1 "2012-11-29T01:11:32Z")

</div>

很多网友平时如果需要在Android平台下开发处理图片裁剪的应用，如果感觉实现的逻辑比较麻烦，比如说需要写类此Win32下的橡皮筋类CRectTracker来设置裁剪区域，这里Android开发网给大家一个最简单可靠的方法，通过下面的Intent调用系统的Camera程序的裁剪功能实现图片修剪。

Intent intent = new Intent(“com.android.camera.action.CROP”);  
intent.setClassName(“com.android.camera”, “com.android.camera.CropImage”);

不过这里Android123提醒大家可能会出现无法找到Activity的android.content.ActivityNotFoundException异常，这是由于Android内部的gallery和camera都有处理，可以尝试另一种URI，com.android.gallery的com.android.camera.CropImage，在setClassName时，具体的代码为

final Intent intent = new Intent(“com.android.camera.action.CROP”);  
intent.setClassName(“com.android.camera”, “com.android.camera.CropImage”);  
intent.setData(Uri.fromFile(mFile));  
intent.putExtra(“outputX”, width);  
intent.putExtra(“outputY”, height);  
intent.putExtra(“aspectX”, width);  
intent.putExtra(“aspectY”, height);  
intent.putExtra(“scale”, true);  
intent.putExtra(“noFaceDetection”, true);  
intent.putExtra(“output”, Uri.parse(“file:/” + mFile.getAbsolutePath()));  
startActivityForResult(intent, REQUEST\_CROP\_IMAGE);
