GithubHelp home page GithubHelp logo

isabella232 / react-native-image-cropper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from discord/react-native-image-cropper

0.0 0.0 0.0 658 KB

Crop your images with zoom and pan

Home Page: https://www.npmjs.com/package/react-native-image-cropper

License: MIT License

JavaScript 64.59% Python 7.74% Java 6.93% Objective-C 20.75%

react-native-image-cropper's Introduction

react-native-image-cropper

Greenkeeper badge

This Image cropper is based on the gl-react-native library

Cropping View

Installation

npm i -S react-native-image-cropper

or

yarn add react-native-image-cropper

Requirements

  • gl-react You need to install gl-react. npm i -S gl-react
  • gl-react-native You need to install gl-react-native and link the repo in RN. npm i -S gl-react-native & rnpm link
  • react-native Android requires you to have RN 0.28 or higher!

{ImageCrop} Props

  • image (required): uri to image that should be cropped.
  • cropHeight (required): height of the image in cropped size.
  • cropWidth (required): width of the image in cropped size.
  • zoom: range 0 - 100 setting zoom value. where 100 = full zoom. (default: 0)
  • maxZoom: max zoom value, should be bigger than minZoom value (default: 100)
  • minZoom: min zoom value, should be smaller than maxZoom value (default: 0)
  • panToMove: Use pan to move image? (default: true)
  • pinchToZoom Use pinch to zoom image? (default: true)
  • quality: a value from 0 to 1 to describe the quality of the snapshot. 0 means 0% (most compressed) and 1 means 100% (best quality). (default: 1)
  • type: the file type default value is "png", "jpg" is also supported. Refer to implementations to see more supported values. (default: jpg)
  • format: the format of the output. Supported values: "base64", "file". (default: base64)
  • filePath: if format is "file", the path to write the image to (default: "")
  • pixelRatio: the pixel ratio to use for the rendering. By default the screen pixel scale will be used.

{ImageCrop} Functions

  • crop(): returns a base64 encoded image.

Example

...
import {ImageCrop} from 'react-native-image-cropper'


...
render() {
  return (
  <View>
    <ImageCrop 
      ref={'cropper'}
      image={this.state.image}
      cropHeight={this.state.height}
      cropWidth={this.state.width}
      zoom={this.state.zoom}
      maxZoom={80}
      minZoom={20}
      panToMove={true}
      pinchToZoom={true}
    />
    <Text onPress={this.capture()}>Capture()</Text>
  </View>
    
  )
} 
capture(){
  this.refs.cropper.crop()
  .then(base64 => console.log(base64))
}
...

react-native-image-cropper's People

Contributors

aprex avatar computerjazz avatar greenkeeper[bot] avatar ketn avatar magrinj avatar matihabbas avatar shockdesign avatar st0ffern avatar traviskochel 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.