smartcrop-android
QuadFlask
68
Visit GitHub RepoImage Croppers

smartcrop-android

Android Arsenal Platform API License

smartcrop implementation in Java(Android)

This library will analyze best crop position and size by calculating some features; edge, skin tone, staturation and face.

original javascript version

Screenshot

Sample app screenshot 1

Sample app screenshot 2

Usage

With RxJava(+RxAndroid)

SmartCrop
    .analyzeWithObservable(Options.newInstance().cropSquareSize(200), selectedImage)
    .subscribeOn(Schedulers.computation())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Action1<CropResult>() {
        @Override
        public void call(CropResult cropResult) {
            // do what you want
        }
    });

Without Rx

But I recommend using RxJava or background thread because it took some times(about 500ms on 2013 Nexus5) so that it may stop the UI refresh and make bad UX.

// this code will block about 500ms
CropResult cropResult = SmartCrop.analyze(Options.newInstance().cropSquareSize(200), selectedImage);

Output

CropResult.java

public class CropResult {
    public final Crop topCrop; // The best cropx, y, width, height and score
    public final List<Crop> crops; // crop candidates
    public final Bitmap debugImage;
    public final Bitmap resultImage; // cropped image from original image. Size is same with options.cropWidth/Height
}

How to add dependency?

This library is not released in Maven Central, but instead you can use JitPack

add remote maven url

repositories {
    maven {
        url "https://jitpack.io"
    }
}

then add a library dependency

dependencies {
    compile 'com.github.QuadFlask:smartcrop-android:0.0.1'
}

or, you can manually download aar and put into your project's libs directory.

and add dependency

dependencies {
    compile(name:'[arrFileName]', ext:'aar')
}

check out [latestVersion] at releases

Features

skin, edge, staturation is almost same with javascript version. Android's face detection is used which draw white circle at face

License

The MIT License (MIT)

Copyright 2014-2015 QuadFlask

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer
Microsoft

Become Pro in Android by watching videos

OUR LEARNERS WORK AT