{"id":22192552,"url":"https://github.com/3sidedcube/imagecropper","last_synced_at":"2025-07-09T08:04:40.887Z","repository":{"id":174625219,"uuid":"623369385","full_name":"3sidedcube/ImageCropper","owner":"3sidedcube","description":"A version of the image cropper library that allows scrolling on the shadowed parts of the selected image.","archived":false,"fork":false,"pushed_at":"2023-04-04T10:12:36.000Z","size":13154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-24T20:45:41.717Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/3sidedcube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["canato","vanniktech"]}},"created_at":"2023-04-04T08:30:41.000Z","updated_at":"2023-04-04T08:32:08.000Z","dependencies_parsed_at":"2023-07-30T03:15:22.903Z","dependency_job_id":null,"html_url":"https://github.com/3sidedcube/ImageCropper","commit_stats":null,"previous_names":["3sidedcube/imagecropper"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/3sidedcube/ImageCropper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2FImageCropper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2FImageCropper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2FImageCropper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2FImageCropper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3sidedcube","download_url":"https://codeload.github.com/3sidedcube/ImageCropper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2FImageCropper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264419452,"owners_count":23605197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T12:26:02.214Z","updated_at":"2025-07-09T08:04:40.867Z","avatar_url":"https://github.com/3sidedcube.png","language":"Kotlin","funding_links":["https://github.com/sponsors/canato","https://github.com/sponsors/vanniktech"],"categories":[],"sub_categories":[],"readme":"[![CanHub](.documentation/art/cover.png?raw=true)](https://github.com/canhub)\n\nAndroid Image Cropper\n=====================\n\n- **Powerful** (Zoom, Rotation, Multi-Source)\n- **Customizable** (Shape, Limits, Style)\n- **Optimized** (Async, Sampling, Matrix)\n- **Simple** image cropping library for Android\n\n![Crop demo](.documentation/art/showcase-1.gif?raw=true)\n\n## Add to your project\n\n```groovy\ndependencies {\n  implementation(\"com.vanniktech:android-image-cropper:4.5.0\")\n}\n```\n\n## Using the Library\n\nThere are 3 ways of using the library. Check out the sample app for all details.\n\n### [1. Calling crop directly](./sample/src/main/kotlin/com/canhub/cropper/sample/SampleCrop.kt)\n\n```kotlin\nclass MainActivity {\n  private val cropImage = registerForActivityResult(CropImageContract()) { result -\u003e\n    if (result.isSuccessful) {\n      // Use the returned uri.\n      val uriContent = result.uriContent\n      val uriFilePath = result.getUriFilePath(context) // optional usage\n    } else {\n      // An error occurred.\n      val exception = result.error\n    }\n  }\n\n  private fun startCrop() {\n    // Start picker to get image for cropping and then use the image in cropping activity.\n    cropImage.launch(\n      options {\n        setGuidelines(Guidelines.ON)\n      }\n    )\n\n    // Start picker to get image for cropping from only gallery and then use the image in cropping activity.\n    cropImage.launch(\n      options {\n        setImagePickerContractOptions(\n          PickImageContractOptions(includeGallery = true, includeCamera = false)\n        )\n      }\n    )\n\n    // Start cropping activity for pre-acquired image saved on the device and customize settings.\n    cropImage.launch(\n      options(uri = imageUri) {\n        setGuidelines(Guidelines.ON)\n        setOutputCompressFormat(CompressFormat.PNG)\n      }\n    )\n  }\n}\n```\n\n### [2. Using CropView](./sample/src/main/kotlin/com/canhub/cropper/sample/SampleUsingImageView.kt)\n\n- Add `CropImageView` into your activity\n\n```xml\n\u003c!-- Image Cropper fill the remaining available height --\u003e\n\u003ccom.canhub.cropper.CropImageView\n  android:id=\"@+id/cropImageView\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"0dp\"\n  android:layout_weight=\"1\"\n  /\u003e\n```\n\n- Set image to crop\n\n```kotlin\ncropImageView.setImageUriAsync(uri)\n// Or prefer using uri for performance and better user experience.\ncropImageView.setImageBitmap(bitmap)\n```\n\n- Get cropped image\n\n```kotlin\n// Subscribe to async event using cropImageView.setOnCropImageCompleteListener(listener)\ncropImageView.getCroppedImageAsync()\n// Or.\nval cropped: Bitmap = cropImageView.getCroppedImage()\n```\n\n### [3. Extend to make a custom activity](./sample/src/main/kotlin/com/canhub/cropper/sample/SampleCustomActivity.kt)\n\nIf you want to extend the `CropImageActivity` please be aware you will need to set up your `CropImageView`\n\n- Add `CropImageActivity` into your AndroidManifest.xml\n```xml\n\u003c!-- Theme is optional and only needed if default theme has no action bar. --\u003e\n\u003cactivity\n  android:name=\"com.canhub.cropper.CropImageActivity\"\n  android:theme=\"@style/Base.Theme.AppCompat\"\n  /\u003e\n```\n\n- Set up your `CropImageView` after call `super.onCreate(savedInstanceState)`\n\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n  super.onCreate(savedInstanceState)\n  setCropImageView(binding.cropImageView)\n}\n```\n\n#### Custom dialog for image source pick\n\nWhen calling crop directly the library will prompt a dialog for the user choose between gallery or camera (If you keep both enable).\nWe 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)_\n\n```kotlin\noverride fun showImageSourceDialog(openSource: (Source) -\u003e Unit) {\n  super.showImageSourceDialog(openCamera)\n}\n```\n\n## Posts\n\n - [Android cropping image from camera or gallery](https://canato.medium.com/android-cropping-image-from-camera-or-gallery-fbe732800b08)\n\n## Migrating from Android Image Cropper\n\nStart by using [Version 4.3.3](https://github.com/CanHub/Android-Image-Cropper/releases/tag/4.3.3):\n\n```groovy\ndependencies {\n  implementation(\"com.vanniktech:android-image-cropper:4.3.3\")\n}\n```\n\n### Update all imports\n\n```diff\n-import com.theartofdev.edmodo.cropper.CropImage\n-import com.theartofdev.edmodo.cropper.CropImageActivity\n+import com.canhub.cropper.CropImage\n+import com.canhub.cropper.CropImageActivity\n```\n\n### Update all XML references\n\n```diff\n-\u003ccom.theartofdev.edmodo.cropper.CropImageView\n+\u003ccom.canhub.cropper.CropImageView\n```\n\nWhen using Activity Contracts, consult with the sample app on how to use our Activity Contracts since `onActivityResult` got deprecated.\n\nVersions after 4.3.3 have changed the APIs quite a bit, it's best to upgrade to each minor version individually, remove deprecated API usages and continue upgrading. So after using 4.3.3, upgrade to 4.4.0, etc.\n\n## License\n\nForked from [ArthurHub](https://github.com/ArthurHub/Android-Image-Cropper)\nOriginally forked from [edmodo/cropper](https://github.com/edmodo/cropper).\n\nCopyright 2016, Arthur Teplitzki, 2013, Edmodo, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this work except in compliance with the   License.\nYou may obtain a copy of the License in the LICENSE file, or at:\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3sidedcube%2Fimagecropper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3sidedcube%2Fimagecropper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3sidedcube%2Fimagecropper/lists"}