public byte[] decompressCropAndRecompressJpegData(final byte[] jpegData,Rect crop,int recompressionQuality){
  Bitmap original=BitmapFactory.decodeByteArray(jpegData,0,jpegData.length);
  final Bitmap croppedResult=Bitmap.createBitmap(original,crop.left,crop.top,crop.width(),crop.height());
  ;
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  croppedResult.compress(Bitmap.CompressFormat.JPEG,recompressionQuality,stream);
  return stream.toByteArray();
}

public byte [ ] decompressCropAndRecompressJpegData ( final byte [ ] jpegData , Rect crop , int recompressionQuality ) { Bitmap original = BitmapFactory . decodeByteArray ( jpegData , 0 , jpegData . length ) ; final Bitmap croppedResult = Bitmap . createBitmap ( original , crop . left , crop . top , crop . width ( ) , crop . height ( ) ) ; ; ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; croppedResult . compress ( Bitmap . CompressFormat . JPEG , recompressionQuality , stream ) ; return stream . toByteArray ( ) ; }
implement cropping through the decompression and re - compression of the jpeg using the built - in android bitmap utilities .
