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
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
Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.

Subsampling Scale Image View A custom image view for Android, designed for photo galleries and displaying huge images (e.g. maps and building plans) w

null 7.4k Jan 8, 2023
An open source Android library that allows the visualization of large images with gesture capabilities

ByakuGallery ByakuGallery is an open source Android library that allows the visualization of large images with gesture capabilities. This lib is based

Diego Lima 311 Dec 4, 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
Android ImageView that handles animated GIF images

GifImageView Android ImageView that handles Animated GIF images Usage In your build.gradle file: dependencies { compile 'com.felipecsl:gifimageview:

Felipe Lima 1.1k Mar 9, 2021
A gallery used to host an array of images

ImageGallery Overview A gallery used to host an array of images You can add one or more images to the gallery Support for using Palette to set the bac

Etienne Lawlor 645 Dec 18, 2022
DMIV aims to provide a flexible and customizable instrument for automated images moving on display. It provides scroll, gyroscope or time based moving. But you can create your own evaluator.

DexMovingImageView DMIV aims to provide a flexible and customizable instrument for automated images moving on display. It provides scroll, gyroscope o

Diego Grancini 310 Feb 7, 2022
TouchPhotoViewer - A project configured with the AndroidX SDK 21 and and higher

TouchPhotoViewer A project configured with the AndroidX SDK 19 and and higher License Copyright (C) 2022 by HoangChung Licensed Licensed under the Apa

hoangchung 2 Jun 1, 2022
Android library to generate image avatar from the first letter of a username. Letter avatar like Gmail Android best practice

AvatarImageGenerator Generate first letter avatar Image like gmail's contact avatar. It generates an drawable that can be be set to an ImageView. Inst

Korir Amos 61 Sep 25, 2022
Android library written in kotlin that add a noise effect to image.

NoiseView With NoiseView you can easily add a noise effect to your image. See demo on YouTube Setup The library is pushed to jCenter() as an AAR, so y

Przemek 46 Sep 8, 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
This is a library for make auto slide image in android

Auto Image Slider Screenshot Image Slider Default Image Slider With Custom Adapter Usage Add ImageSlider to your layout

Afdhal_FA 17 Dec 1, 2022
Android Blurred ImageSwitcher Library

Android Blurred ImageSwitcher Library

Chrisvin Jem 48 Jul 2, 2022
A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows

A library for Android provides blurred drop shadows to ImageView similar to iOS image backdrop shadows.Provides fast canvas draw as no renderscript needed .The similar shadow blurred effects can also be seen in iOS Music App.

Vivek Verma 163 Dec 31, 2022
Custom ImageView for android with polygon shape (Android)

PolygonImageView Create a custom ImageView with polygonal forms. Usage To use PolygonImageView, add the module into your project and start to build xm

Albert Grobas 531 Dec 25, 2022
Implementation of ImageView for Android that supports zooming, by various touch gestures.

PhotoView PhotoView aims to help produce an easily usable implementation of a zooming Android ImageView. [ Dependency Add this in your root build.grad

Baseflow 18.4k Dec 30, 2022
A circular ImageView for Android

CircleImageView A fast circular ImageView perfect for profile images. This is based on RoundedImageView from Vince Mi which itself is based on techniq

Henning Dodenhof 13.8k Mar 29, 2021
Android filters based on OpenGL (idea from GPUImage for iOS)

GPUImage for Android Idea from: iOS GPUImage framework Goal is to have something as similar to GPUImage as possible. Vertex and fragment shaders are e

CATS Open Source Softwares 8.6k Jan 8, 2023