st0ffern / react-native-image-cropper

Crop your images with zoom and pan
https://www.npmjs.com/package/react-native-image-cropper
MIT License
158 stars 67 forks source link
cropper image-cropper pan react-native

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

{ImageCrop} Props

{ImageCrop} Functions

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))
}
...