Skip to content

Android widget for cropping image, optimized for picked image from Camera or Gallery.

License

Notifications You must be signed in to change notification settings

monisha1/Android-Image-Cropper

 
 

Repository files navigation

Android Image Cropper

build status Codacy Badge Download

Image cropping tool, displays a resizable, rectengular/oval crop window on top of image.

Optimized for cropping image picked from Camera or Gallery

Crop

Usage

For a working implementation, please have a look at the Sample Project

  1. Include the library
compile 'com.theartofdev.edmodo:android-image-cropper:1.2.+'
  1. Add CropImageView into your activity
<!-- Image Cropper fill the remaining available height -->
<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:cropScaleType="fitCenter"/>
  1. Set image to crop
cropImageView.setImageBitmap(bitmap);
// or
cropImageView.setImageUriAsync(uri);
  1. Get cropped image
Bitmap cropped = cropImageView.getCroppedImage();
// or (must subscribe to async event using cropImageView.setOnGetCroppedImageCompleteListener(listener))
cropImageView.getCroppedImageAsync(CropImageView.CropShape.RECTANGLE, 400, 400);

Features

  • Set cropping image as Bitmap, Resource or Android URI (Gallery, Camera, Dropbox, etc.).
  • Set cropping window shape to Rectengular or Oval (cube/circle by fixing aspect ration).
  • Rotate image to allow the user to rotate the image during cropping.
  • Auto rotate bitmap by provided Exif data or loading from Android URI.
  • Set image Scale type in the cropping image view: center or fit.
  • Set result image min/max limits in pixels.
  • Get cropping rectangle or the cropped bitmap.
  • Using sampling to reduce memory usage and prevent out-of-memory.
  • Support required size and sampling on getting cropped image for memory optimization.
  • Supported on API Level 10 and above.

Customizations

  • Cropping window aspect ratio: Free, 1:1, 4:3, 16:9 or Custom.
  • Guidelines appearance: Off / Always On / Show on Toch.
  • Cropping window Border line, border corner and guidelines thickness and color.
  • Cropping background color.

For more information, see the linked Github Wiki page.

Posts

Change log

1.2.3

  • Fix getActualCropRect to adjust by sampling size for images loaded from URI.
  • Fix crop window size bounded with fixed aspect ratio and move of a single edge.
  • Added CropImageHelper class to simplify cropping image work.

1.2.2 (beta)

  • Fix setShowCropOverlay(boolean) not working properly.
  • Fix crop window bounds issue when cropping image is too small relative to min/max bounds with fixed aspect ratio.
  • Fix crop window reset on on-screen keyboard show/hide.

See full change log.

License

Forked from edmodo/cropper fixing some bugs and adding some features.

Copyright 2013, Edmodo, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Android widget for cropping image, optimized for picked image from Camera or Gallery.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%