Git Product home page Git Product logo

imagecropper's Introduction

ImageCropper

A custom image cropper library on Android

Features

  • Support moving/scale the crop window freely by finger
  • Support set a fixed crop window size
  • Support set the max crop window size
  • Support set a fixed crop window's width/height aspect
  • Support rotate the image when cropping
  • Easy to integrate into your app

ScreenShot

Dependency

(1) Add it in your root build.gradle at the end of repositories:

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

(2) Add the dependency

allprojects {
    compile 'com.github.Jhuster:ImageCropper:v1.1.1'
}

Usage

Declare the CropImageActivity in the main project's AndroidManifest.xml

<activity android:name="com.jhuster.imagecropper.CropImageActivity"/>

Declare the write_external_storage permission in the main project's AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Call these methods to run CropImage Activity

//1. Using the CropIntent to help build the start intent
private void startCropImage() {

    // Create a CropIntent
    CropIntent intent = new CropIntent();

    // Set the source image filepath/URL and output filepath/URL (Optional)
    //intent.setImagePath("/sdcard/source.jpg");
    intent.setOutputPath("/sdcard/cropped.jpg");

    // Set a fixed crop window size (Optional)
    //intent.setOutputSize(640,480);

    // set the max crop window size (Optional)
    //intent.setMaxOutputSize(800,600);

    // Set a fixed crop window's width/height aspect (Optional)
    //intent.setAspect(3,2);

    // start ImageCropper activity with certain request code and listen for result
    startActivityForResult(intent.getIntent(this), 0);
}

Waiting for result

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode != RESULT_OK) {
        return;
    }

    if (requestCode == 0) {
        Uri croppedUri = data.getExtras().getParcelable(MediaStore.EXTRA_OUTPUT);
        InputStream in = null;
        try {
            in = getContentResolver().openInputStream(croppedUri);
            Bitmap b = BitmapFactory.decodeStream(in);
            //mImageView.setImageBitmap(b);
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

Contact

Email:[email protected]

imagecropper's People

Contributors

jhuster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

imagecropper's Issues

Application Crash On Save

Steps to reproduce issue

  1. Click on button which call startCropImage() method
  2. Don't select any image and press back
  3. Now click on save button

Application crash on save button

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.