GithubHelp home page GithubHelp logo

react-native-image-cropper-thanhtq's Introduction

react-native-image-cropper-thanhtq

Result

iOS Installation

do it manually as described below:

  1. Run npm install react-native-image-cropper-thanhtq --save
  2. Open your project in XCode, right click on Libraries and click Add Files to "Your Project Name" Look under node_modules/react-native-image-cropper-thanhtq and add TOCropViewController.xcodeproj.
  3. Add libImageCropperManager.a to Build Phases -> Link Binary With Libraries
  4. Done!

Android Installation

Run npm install react-native-image-cropper-thanhtq --save You can use the React Native CLI to add native dependencies automatically: $ react-native link react-native-image-cropper-thanhtq

Manual setup

In android/settings.gradle

...

include ':react-native-image-cropper-thanhtq'
project(':react-native-image-cropper-thanhtq').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-cropper-thanhtq/android')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-image-cropper-thanhtq')
}

Register module (in MainApplication.java)

import com.cropimagepicker.cropper.ImageCropperPackage; // <--- Import Package

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new ImageCropperPackage() // <--- Initialize the package
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

Usage

  1. For Android:
import ImageCropper from 'react-native-image-cropper-thanhtq'

let options = {
            guideLines: 'on-touch',
            cropShape: 'rectangle',
            title: 'CROP AVATAR',
            cropMenuCropButtonTitle: 'Done',
            uri_image: response.path,
            fixAspectRatio: true
          }
 ImageCropper.selectImage(options, (responseCrop) => {
    if (responseCrop && responseCrop.uri) { // uri = 'file://' + path
        console.log("UIr crop", responseCrop.uri)
              // crop succeeded
    } else if(responseCrop.error){
              //error handling
    }
  });
  1. For iOS:
import ImageCropper from 'react-native-image-cropper-thanhtq';
let options = {
   urlBase64Image: 'data:image/jpg;base64,' + response.data,
   path: response.uri
 }
ImageCropper.showViewCrop(options, (data) => {
   let encodedData = data
   let newUri = `data:image/jpg;base64,${encodedData}`
 })

----------------------END------------------------

react-native-image-cropper-thanhtq's People

Contributors

thanhit93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-image-cropper-thanhtq's Issues

Fixed size for crop area

For example I need to have to crop all my pictures to 200x100 pixel.
Can I do this with react-native-image-cropper-thanhtq

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.