Code Monkey home page Code Monkey logo

ucrop's Introduction

uCrop - Image Cropping Library for Android

This project aims to provide an ultimate and flexible image cropping experience. Made in [Yalantis] (https://yalantis.com/?utm_source=github)

alt text

Usage

For a working implementation, please have a look at the Sample Project - sample

Get it on Google Play

  1. Include the library as local library project.

    compile 'com.yalantis:ucrop:1.0.0'

  2. Add UCropActivity into your AndroidManifest.xml

    <activity
        android:name="com.yalantis.ucrop.UCropActivity"
        android:screenOrientation="portrait"/>
    
  3. The uCrop configuration is created using the builder pattern.

    UCrop.of(sourceUri, destinationUri)
        .withAspectRatio(16, 9)
        .withMaxResultSize(maxWidth, maxHeight)
        .start(context);
  4. Override onActivityResult method and handle uCrop result.

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
            final Uri resultUri = UCrop.getOutput(data);
        } else if (resultCode == UCrop.RESULT_ERROR) {
            final Throwable cropError = UCrop.getError(data);
        }
    }

Customization

If you want to let your users choose crop ratio dynamically, just do not call withAspectRatio(x, y).

uCrop builder class has method withOptions(UCrop.Options option) which extends library configurations.

Currently you can change:

  • image compression format (e.g. PNG, JPEG, WEBP), compression
  • image compression quality [0 - 100]. PNG which is lossless, will ignore the quality setting.
  • whether all gestures are enabled simultaneously
  • maximum size for Bitmap that is decoded from source Uri and used within crop view. If you want to override default behaviour.
  • more coming... (e.g. color pallet)

Compatibility

  • Library - Android GINGERBREAD 2.3+
  • Sample - Android ICS 4.0+

Changelog

Version: 1.0

  • Initial Build

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the library.

License

Copyright 2016, Yalantis

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.

ucrop's People

Contributors

shliama avatar

Watchers

James Cloos avatar Razerdp 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.