Skip to content

Set initial crop window rectangle

Arthur edited this page May 17, 2016 · 2 revisions

By default the initial crop window is set to cover 80% of the cropping image, having 10% padding from the image borders.
If fixed aspect ratio is set then the larger dimension will fit within padding and the smaller dimension will adjust by aspect ratio restriction.

Set initial crop window to cover 100% of the cropping image

You can change the initial crop window padding ratio and set it to 0.
On CropImageActivity:

CropImage.activity(imageUri)
  .setInitialCropWindowPaddingRatio(0)
  .start(this);

or on CropImageView:

<com.theartofdev.edmodo.cropper.CropImageView
  xmlns:custom="http://schemas.android.com/apk/res-auto"
  android:id="@+id/cropImageView"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"
  custom:cropInitialCropWindowPaddingRatio="0"/>

Set initial crop window to specific rectangle

If you know the best initial cropping window rectangle, using face detection for example, you can set it.
On CropImageActivity:

CropImage.activity(imageUri)
  .setInitialCropWindowRectangle(myRect)
  .start(this);

or on CropImageView:

mCropImageView.setCropRect(myRect);