Git Product home page Git Product logo

durban's Introduction

Durban is an MD-style picture cropping tool that combines the image selection tool with Album Use is the best.

It comes from the uCrop, but I modified most of the code, let it use more friendly.

Recommended image selection library: https://github.com/yanzhenjie/Album

中文文档

Screenshot

Dependencies

  • Gradle:
compile 'com.yanzhenjie:durban:1.0.0'
  • Maven:
<dependency>
  <groupId>com.yanzhenjie</groupId>
  <artifactId>durban</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

Usage

Support Activity, android.app.Fragment, android.support.v4.app.Fragment:

Durban.with(Activity);
Durban.with(android.app.Fragment);
Durban.with(android.support.v4.app.Fragment);

How to call clipping:

Durban.with(this)
    // Che title of the UI.
    .title("Crop")
    .statusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))
    .toolBarColor(ContextCompat.getColor(this, R.color.colorPrimary))
    .navigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryBlack))
    // Image path list/array.
    .inputImagePaths(imagePathList)
    // Image output directory.
    .outputDirectory(cropDirectory)
    // Image size limit.
    .maxWidthHeight(500, 500)
    // Aspect ratio.
    .aspectRatio(1, 1)
    // Output format: JPEG, PNG.
    .compressFormat(Durban.COMPRESS_JPEG)
    // Compress quality, see Bitmap#compress(Bitmap.CompressFormat, int, OutputStream)
    .compressQuality(90)
    // Gesture: ROTATE, SCALE, ALL, NONE.
    .gesture(Durban.GESTURE_ALL)
    .requestCode(200)
    .start();

Note: inputImagePaths() method can be a picture path list, can also be a picture path array, such as:

// Such as: 
List<String> imagePathList = ...
Durban.with(this)
    ...
    .inputImagePaths(imagePathList)
    ...

// OR: 
String[] imagePathArray = ...
Durban.with(this)
    ...
    .inputImagePaths(imagePathArray)
    ...

// OR: 
Durban.with(this)
    ...
    .inputImagePaths(path1, path2, path3...)
    ...

And then override the onActivityResult() method to accept the cropping results:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case 200: {
            // Analyze the list of paths after cropping.
            if (resultCode != RESULT_OK) {
                ArrayList<String> mImageList = Durban.parseResult(data);
            } else {
                // TODO other...
            }
            break;
        }
    }
}

Proguard-rules

Durban can be completely confusing, if there is a problem, add the rule to the proguard-rules:

-dontwarn com.yanzhenjie.curban.**
-keep class com.yanzhenjie.curban.**{*;}

-dontwarn com.yanzhenjie.loading.**
-keep class com.yanzhenjie.loading.**{*;}

Thanks

  1. uCrop
  2. Album

License

Copyright 2017 Yan Zhenjie

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.

durban's People

Contributors

shliama avatar larin92 avatar cool04ek avatar simonpercic avatar hearsilent avatar edbaev avatar voltazor avatar teerawk avatar bechau avatar rwliang avatar peterhav avatar timkoers avatar start141 avatar vanniktech avatar kucherenkoihor avatar johnwowus avatar clemp6r avatar dejandobnikar avatar warko-san avatar jasl avatar pgmacdesign avatar meoyawn avatar pylersm avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.