All Projects → akshaaatt → Cropper

akshaaatt / Cropper

Licence: other
Android Library for cropping an image at ease.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Cropper

pikaso
Seamless and headless HTML5 Canvas library
Stars: ✭ 23 (+9.52%)
Mutual labels:  crop, cropper
React Cropper
Cropperjs as React component
Stars: ✭ 1,600 (+7519.05%)
Mutual labels:  crop, cropper
Croppr.js
A vanilla JavaScript image cropper that's lightweight, awesome, and has absolutely zero dependencies.
Stars: ✭ 294 (+1300%)
Mutual labels:  crop, cropper
react-native-avatar-crop
Highly customisable <Crop /> component for React Native < 💅 >
Stars: ✭ 47 (+123.81%)
Mutual labels:  crop, cropper
Rskimagecropper
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
Stars: ✭ 2,371 (+11190.48%)
Mutual labels:  crop, cropper
Tocropviewcontroller
A view controller for iOS that allows users to crop portions of UIImage objects
Stars: ✭ 4,210 (+19947.62%)
Mutual labels:  crop, cropper
Croppy
Image Cropping Library for Android
Stars: ✭ 906 (+4214.29%)
Mutual labels:  crop, cropper
Krop
Small widget for image cropping in Instagram-like style
Stars: ✭ 107 (+409.52%)
Mutual labels:  crop, cropper
Cropiwa
📐 Configurable Custom Crop widget for Android
Stars: ✭ 2,185 (+10304.76%)
Mutual labels:  crop, cropper
Pdfcropmargins
pdfCropMargins -- a program to crop the margins of PDF files
Stars: ✭ 141 (+571.43%)
Mutual labels:  crop, cropper
react-drop-n-crop
An opinionated implementation of react-dropzone and react-cropper
Stars: ✭ 17 (-19.05%)
Mutual labels:  crop, cropper
react-simple-crop
✂️ A React component library for cropping and previewing images
Stars: ✭ 19 (-9.52%)
Mutual labels:  crop, cropper
ngx-cropper
An Angular image plugin, includes upload, cropper, save to server.
Stars: ✭ 14 (-33.33%)
Mutual labels:  crop, cropper
wocket
A WebSocket library for Deno
Stars: ✭ 103 (+390.48%)
Mutual labels:  application
LockerScreen
Android lock screen,slide to unlock ! 安卓锁屏,上滑解锁,效果酷炫,值得拥有!
Stars: ✭ 81 (+285.71%)
Mutual labels:  application
web-fonts-repository
A simple webfont hosting. Google Fonts alternative for your own fonts.
Stars: ✭ 99 (+371.43%)
Mutual labels:  application
app
Aplus Framework App Project
Stars: ✭ 338 (+1509.52%)
Mutual labels:  application
rss-for-the-rest-of-us
A simple RSS reader built on Laravel. For the rest of us.
Stars: ✭ 16 (-23.81%)
Mutual labels:  application
DoubanFilm
利用豆瓣的电影api开发的基于material design的客户端
Stars: ✭ 15 (-28.57%)
Mutual labels:  application
fokus
Mobile application that helps kids complete their daily tasks under parental control
Stars: ✭ 21 (+0%)
Mutual labels:  application

Cropper - Android Image Cropper

GitHub issues GitHub last commit App Logo

Android Image Cropper

Powerful (Zoom, Rotation, Multi-Source); Customizable (Shape, Limits, Style); Optimized (Async, Sampling, Matrix); Simple image cropping library for Android.

Add to your project

Step 1. Add the JitPack repository to your root build.gradle

  allprojects {
     repositories {
       ....
       maven { url 'https://jitpack.io' }
     }
  }

Step 2. Add the dependency

  dependencies {
       implementation 'com.github.akshaaatt:Cropper:1.00'
  }

Using the Library

There is 3 ways of using the library:

  • Calling crop directly (Sample code: app/crop_image)
  • Using the CropView (Sample code: app/crop_image_view)
  • Extending the activity (Sample code: app/extend_activity) Your choice depends on how you want your layout to look.

Obs: The library has a public pick image contract, more on wiki.

Calling crop directly

  • Register for activity result with CropImageContract
class MainActivity {
   private val cropImage = registerForActivityResult(CropImageContract()) { result ->
           if (result.isSuccessful) {
               // use the returned uri
               val uriContent = result.uriContent 
               val uriFilePath = result.getUriFilePath(context) // optional usage
           } else {
               // an error occurred
               val exception = result.error
           }
       }

   private fun startCrop() {
       // start picker to get image for cropping and then use the image in cropping activity
       cropImage.launch(
           options {
               setGuidelines(Guidelines.ON)
           }
       )

       //start picker to get image for cropping from only gallery and then use the image in
       //cropping activity
       cropImage.launch(
           options {
               setImagePickerContractOptions(
                   PickImageContractOptions(includeGallery = true, includeCamera = false)
               )
           }
       )

       // start cropping activity for pre-acquired image saved on the device and customize settings
       cropImage.launch(
           options(uri = imageUri) {
               setGuidelines(Guidelines.ON)
               setOutputCompressFormat(CompressFormat.PNG)
           }
       )
   }
}

Using CropView

  1. Add CropImageView into your activity
<!-- Image Cropper fill the remaining available height -->
<com.aemerse.cropper.CropImageView
  android:id="@+id/cropImageView"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"/>
  1. Set image to crop
cropImageView.setImageUriAsync(uri)
// or (prefer using uri for performance and better user experience)
cropImageView.setImageBitmap(bitmap)
  1. Get cropped image
// subscribe to async event using cropImageView.setOnCropImageCompleteListener(listener)
cropImageView.getCroppedImageAsync()
// or
val cropped: Bitmap = cropImageView.getCroppedImage()

Extend to make a custom activity

If you want to extend the CropImageActivity please be aware you will need to setup your CropImageView You can check a sample code in this project com.aemerse.cropper.app.extend_activity.app.SExtendActivity

  • Add CropImageActivity into your AndroidManifest.xml
<activity android:name="com.aemerse.cropper.CropImageActivity"
  android:theme="@style/Base.Theme.AppCompat"/> <!-- optional (needed if default theme has no action bar) -->
  • Setup your CropImageView after call super.onCreate(savedInstanceState)
override fun onCreate(savedInstanceState: Bundle?) {
   super.onCreate(savedInstanceState)
   setCropImageView(binding.cropImageView)
}

Custom dialog for image source pick

When calling crop directly the library will prompt a dialog for the user choose between gallery or camera (If you keep both enable). We use the Android default AlertDialog for this. If you wanna customised it with your app theme you need to override the method showImageSourceDialog(..) when extending the activity (above)

override fun showImageSourceDialog(openSource: (Source) -> Unit) {
     super.showImageSourceDialog(openCamera)
}

Features

  • Built-in CropImageActivity.
  • Set cropping image as Bitmap, Resource or Android URI (Gallery, Camera, Dropbox, etc.).
  • Image rotation/flipping during cropping.
  • Auto zoom-in/out to relevant cropping area.
  • Auto rotate bitmap by image Exif data.
  • Set result image min/max limits in pixels.
  • Set initial crop window size/location.
  • Request cropped image resize to specific size.
  • Bitmap memory optimization, OOM handling (should never occur)!
  • API Level 14.
  • More..

Customizations

  • Cropping window shape: Rectangular, Oval (square/circle by fixing aspect ratio), as well as rectangular modes which only allow vertical or horizontal cropping.
  • Cropping window aspect ratio: Free, 1:1, 4:3, 16:9 or Custom.
  • Guidelines appearance: Off / Always On / Show on Touch.
  • Cropping window Border line, border corner and guidelines thickness and color.
  • Cropping background color.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].