Android library project for cropping images

Overview

I guess people are just cropping out all the sadness

An Android library project that provides a simple image cropping Activity, based on code from AOSP.

Deprecated! This project is not maintained. If it doesn't meet your needs as is, consider creating a fork or picking from these alternatives.

maven central changelog

Features

  • Gradle build & AAR
  • Modern UI
  • Backwards compatible to SDK 10
  • Simple builder for configuration
  • Example project

Usage

First, declare CropImageActivity in your manifest file:

<activity android:name="com.soundcloud.android.crop.CropImageActivity" />

Crop

Crop.of(inputUri, outputUri).asSquare().start(activity)

Listen for the result of the crop (see example project if you want to do some error handling):

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result) {
    if (requestCode == Crop.REQUEST_CROP && resultCode == RESULT_OK) {
        doSomethingWithCroppedImage(outputUri);
    }
}

Some attributes are provided to customise the crop screen. See the example project theme.

Pick

The library provides a utility method to start an image picker:

Crop.pickImage(activity)

Dependency

The AAR is published on Maven Central:

compile 'com.soundcloud.android:android-crop:1.0.1@aar'

How does it look?

android-crop screenshot

License

This project is based on the AOSP camera image cropper via android-cropimage.

Copyright 2016 SoundCloud

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License 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.
Comments
  • IllegalArgumentException: Unknown column requested: _data

    IllegalArgumentException: Unknown column requested: _data

    In Google Play I have the following stack trace

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.krittiq.app/com.soundcloud.android.crop.CropImageActivity}: java.lang.IllegalArgumentException: Unknown column requested: _data
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
    at android.app.ActivityThread.access$800(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.IllegalArgumentException: Unknown column requested: _data
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
    at android.content.ContentProviderProxy.query(ContentProviderNative.java:413)
    at android.content.ContentResolver.query(ContentResolver.java:461)
    at android.content.ContentResolver.query(ContentResolver.java:404)
    at com.soundcloud.android.crop.CropUtil.getFromMediaUri(CropUtil.java:95)
    at com.soundcloud.android.crop.CropImageActivity.setupFromIntent(CropImageActivity.java:126)
    at com.soundcloud.android.crop.CropImageActivity.onCreate(CropImageActivity.java:79)
    at android.app.Activity.performCreate(Activity.java:5231)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
    ... 12 more
    

    Device: n7000 (Android 4.4)

    crash 
    opened by akohout 12
  • withMaxSize(x,y) not working

    withMaxSize(x,y) not working

    First, thank you for your perfect code : ) I want to crop image to 300*300 on android 4.1.2 , and my code like this: new Crop(inputUri).output(outputUri).withMaxSize(300, 300).asSquare().start(mActivity); But I found it does not work. So I rewrite some code in the library's source code.

    In line:339 croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options()); changed to Options options = new BitmapFactory.Options(); options.inSampleSize = width / maxX; if(options.inSampleSize <= 0) { options.inSampleSize = 1; } croppedImage = decoder.decodeRegion(rect, options);

    Finally, thanks again.

    bug 
    opened by bbdlg 12
  • How to crop image capture from camera?

    How to crop image capture from camera?

    Can possible to use this code for crop image taken from a camera. I have tried for camera image, but it's return null pointer exception. i.e. Caused by: java.lang.NullPointerException

    opened by shaileshmulange 11
  • Current .start(Activity activity) functionality is limiting.

    Current .start(Activity activity) functionality is limiting.

    Only allowing the crop activity to be started via an activity is a bit restrictive, I'm trying to deliver my result to a fragment's onActivityResult instead of an activity and also add some extras to the intent that is returned. I know this is vague but some more control over launching the activity/returning a result would be very helpful.

    enhancement 
    opened by zsperske 10
  • Failed to resolve: com.soundcloud.android:android-crop:1.0.0

    Failed to resolve: com.soundcloud.android:android-crop:1.0.0

    I'm trying to add the library to my android project. I added compile 'com.soundcloud.android:android-crop:1.0.0' to my app.gradle file. But it fails with:

    Error:(27, 13) Failed to resolve: com.soundcloud.android:android-crop:1.0.0
    <a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
    

    Any idea?

    opened by gmunumel 8
  • Possibility to send cropped image result to server as png?

    Possibility to send cropped image result to server as png?

    I noticed that the cropped image result can be seen as a string like this file:///data/data/com.myapp.test/cache/cropped but doesn't have a file/format extension. How, if possible, can I retrieve that image for uploading to a server?

    opened by power7714 7
  • Usage with Camera Intent?

    Usage with Camera Intent?

    Hello,

    This library works great for ImagePicker. Does this work with Camera capture intent? If yes, are there any examples available?

    Thanks in advance.

    opened by xaxist 7
  • Are you using android-crop in your app?

    Are you using android-crop in your app?

    I'd like to collect some more examples for the README. Please consider leaving a comment below and link to an app you've published that uses this library. Thanks!

    question 
    opened by jdamcd 6
  • Image failed to decode using GIF decoder

    Image failed to decode using GIF decoder

    I've seen ~60 instances of this issue among my userbase. Has anyone else seen this? I am wondering if my users are trying to crop GIF images, and maybe GIFs are not supported?

    java.lang.Exception: Crop.RESULT_ERROR from crop: file:///storage/emulated/0/WOInvoice/picture/logo.png
        at com.aadhk.woinvoice.util.LogoUtils.void handleCrop(int,android.content.Intent)(ProGuard:188)
        at com.aadhk.woinvoice.util.LogoUtils.void onActivityResult(int,int,android.content.Intent)(ProGuard:121)
        at com.aadhk.woinvoice.LogoActivity.void onActivityResult(int,int,android.content.Intent)(ProGuard:75)
        at android.app.Activity.dispatchActivityResult(Activity.java:5581)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:3517)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3564)
        at android.app.ActivityThread.access$1300(ActivityThread.java:163)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5335)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
        at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.io.IOException: Image failed to decode using GIF decoder
        at android.graphics.BitmapRegionDecoder.nativeNewInstance(Native Method)
        at android.graphics.BitmapRegionDecoder.newInstance(BitmapRegionDecoder.java:135)
        at com.soundcloud.android.crop.CropImageActivity.android.graphics.Bitmap decodeRegionCrop(android.graphics.Bitmap,android.graphics.Rect)(ProGuard:342)
        at com.soundcloud.android.crop.CropImageActivity.void onSaveClicked()(ProGuard:303)
        at com.soundcloud.android.crop.CropImageActivity.void removeLifeCycleListener(com.soundcloud.android.crop.MonitoredActivity$LifeCycleListener)(ProGuard:45)
                                                      void access$000(com.soundcloud.android.crop.CropImageActivity)
                                                      com.soundcloud.android.crop.HighlightView access$902(com.soundcloud.android.crop.CropImageActivity,com.soundcloud.android.crop.HighlightView)
                                                      void access$1000(com.soundcloud.android.crop.CropImageActivity,android.graphics.Bitmap)
        at com.soundcloud.android.crop.CropImageActivity$3.void onClick(android.view.View)(ProGuard:107)
        at android.view.View.performClick(View.java:4630)
        at android.view.View$PerformClick.run(View.java:19339)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        ... 7 more
    
    crash 
    opened by alexblack 5
  • Doesn't respect the original orientation

    Doesn't respect the original orientation

    If the original picture is taken with a camera orientation different from default, the cropped photo is rotated (as far as I can tell, the rotation is the negative rotation of the original). I guess the EXIF info is removed or somehow messed up.

    I've tested on multiple devices and it's consistent.

    I'm starting to do some debugging in the source code, but I would appreciate any help understanding the logic. Thanks.

    bug 
    opened by corneliudascalu 5
  • Not compiling.

    Not compiling.

    Importing the .zip 2 projects in Eclipse is a mess. They have no target APIs, the lib is not a lib project, there are no source files, etc.

    It is just built for Gradle?

    opened by rsavutiu 5
  • we can crop out of image size?

    we can crop out of image size?

    we need some feature crop transparency area image like image send crop bigger image size (we have image with 1000 * 1000 but we need to export 2000*2000 image size)

    how to can use this feature by this library we can ?

    imageCrop

    opened by nazemi0101 0
  • 🚨🚨🚨🚨🚨  THIS LIBRARY IS NOT MAINTAINED, PLEASE READ THIS 🚨🚨🚨🚨🚨

    🚨🚨🚨🚨🚨 THIS LIBRARY IS NOT MAINTAINED, PLEASE READ THIS 🚨🚨🚨🚨🚨

    I start a new project to handover another crop library https://github.com/CanHub/Android-Image-Cropper

    The ideia is that we keep improving because this project don’t have updates since 2018 Hope I can count with your help and hope this can help you

    You can check the roadmap in projects And the lib grow in discussions

    Feel free to drop any PR.

    opened by Canato 0
  • OOM Issue When Crop 18 mb up images

    OOM Issue When Crop 18 mb up images

    i'm want to request for report a Bug.

    When Try to crop 18 mb or above images then Application Crash

    For large image link : https://visibleearth.nasa.gov/images/74393/july-blue-marble-next-generation-w-topography

    opened by vickypathak123 1
Releases(1.0.1)
Owner
Jamie McDonald
Jamie McDonald
Image Cropping Library for Android, optimised for Camera / Gallery.

Image Cropping Library for Android, optimised for Camera / Gallery.

CanHub 812 Dec 30, 2022
Image Cropping Library for Android

Image Cropping Library for Android

Lyrebird Studio 1.1k Dec 30, 2022
Image cropping library written with Jetpack Compose with other Composables such as ImageWithConstraints scales Bitmap

Image cropping library written with Jetpack Compose with other Composables such as ImageWithConstraints scales Bitmap it displays and returns position and bounds of Bitmap and ImageWithThumbnail to display thumbnail of the image on selected corner.

Smart Tool Factory 9 Jul 27, 2022
Android widget for cropping and rotating an image.

Cropper The Cropper is an image cropping tool. It provides a way to set an image in XML and programmatically, and displays a resizable crop window on

Edmodo 2.9k Nov 14, 2022
Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image selection.

Awesome Image Picker Awesome Image Picker library will pick images/gifs with beautiful interface. Supports image or gif, Single and Multiple Image sel

Prabhakar Thota 162 Sep 13, 2022
Custom view for circular images in Android while maintaining the best draw performance

CircularImageView Custom view for circular images in Android while maintaining the best draw performance Usage To make a circular ImageView, add this

Pkmmte Xeleon 1.2k Dec 28, 2022
This is an Image slider with swipes, Here we used Volley to Image load URL's from JSON! Here we make it very easy way to load images from Internet and We customized the description font style(OpenSans).

ImageSliderWithSwipes This is an Image slider with swipes, Here we used Volley to load URL's from JSON! Here we make it very easy way to load images f

Prabhakar Thota 44 May 31, 2021
Polygon shaped images

ShapeShifter Provides Polygon shaped imageView Screenshot Usage Step 1. Add the JitPack repository to your build file allprojects { repositori

Dushyant Mainwal 24 Oct 20, 2020
Note saver app which can save images as well with customization.

Note-With-Images-App Note saver app which can save images as well with customization. Demo final.demo.mp4 What i used? Kotlin Paging 3 library flow li

agam koradiya 9 Oct 31, 2022
PixaPay - Images Search client

PixaPay - Images Search client Getting started Signup or Login into Pixabay for getting API_KEY Add APY_KEY="Your_Key_Here" and BASE_URL="https://pixa

Mohamed Ibrahim 6 Nov 6, 2022
An Android project containing image recognition and object detection models.

An Android project containing image recognition and object detection models. Users can input images into the deep learning model by taking photos, opening photo albums, and real-time previews on the Android side. After the calculation on the Android side is completed, the model will output the prediction result and show it to the user.

null 7 Nov 27, 2022
An android image compression library.

Compressor Compressor is a lightweight and powerful android image compression library. Compressor will allow you to compress large photos into smaller

Zetra 6.7k Dec 31, 2022
Customizable Android full screen image viewer for Fresco library supporting "pinch to zoom" and "swipe to dismiss" gestures. Made by Stfalcon

This project is no longer supported. If you're able to switch from Fresco to any other library that works with the Android's ImageView, please migrate

Stfalcon LLC 1.8k Dec 19, 2022
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

Patrick Favre-Bulle 1k Dec 1, 2022
An image resizing library for Android

Resizer Inspired by zetbaitsu's Compressor, Resizer is a lightweight and easy-to-use Android library for image scaling. It allows you to resize an ima

Kakit Ho 426 Dec 22, 2022
Photo picker library for android. Let's you pick photos directly from files, or navigate to camera or gallery.

ChiliPhotoPicker Made with ❀️ by Chili Labs. Library made without DataBinding, RxJava and image loading libraries, to give you opportunity to use it w

Chili Labs 394 Nov 29, 2022
Simple android image popup Library

Android Image Popup Show image as a popup on a click event or any event. Simply set the image as drawable and thats it!!!. And also you can set width,

Chathura Lakmal 64 Nov 15, 2022
Image loading library for Android

Image Loader Image loader library for Android. Deprecated. See Glide. Features Image transformations Automatic memory and storage caching Ability to l

Yuriy Budiyev 19 May 28, 2022
SVG rendering library for Android

AndroidSVG AndroidSVG is a SVG parser and renderer for Android. It has almost complete support for the static visual elements of the SVG 1.1 and SVG 1

Paul LeBeau 1.1k Dec 28, 2022