MCPcopy Index your code
hub / github.com/Michaelvilleneuve/react-native-perspective-image-cropper

github.com/Michaelvilleneuve/react-native-perspective-image-cropper @v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.0 ↗ · + Follow
15 symbols 20 edges 4 files 0 documented · 0% updated 3y agov0.2.0 · 2018-08-27★ 30821 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

React Native perspective image cropper 📐🖼

A component that allows you to perform custom image crop and perspective correction !

Demo image

Designed to work with React Native Document Scanner

https://github.com/Michaelvilleneuve/react-native-document-scanner

Demo gif

Installation 🚀🚀

$ npm install react-native-perspective-image-cropper --save

$ react-native link react-native-perspective-image-cropper

This library uses react-native-svg, you must install it too. See https://github.com/react-native-community/react-native-svg for more infos.

Download opencv2.framework from here https://sourceforge.net/projects/opencvlibrary/files/opencv-ios/2.4.13/ and unzip it in your ios then in XCode, right click on project, choose add files to yourproject and select opencv2.framework

instructions

Crop image

  • First get component ref
<CustomCrop ref={(ref) => this.customCrop = ref} />
  • Then call :
this.customCrop.crop();

Props

Props Type Required Description
updateImage Func Yes Returns the cropped image and the coordinates of the cropped image in the initial photo
rectangleCoordinates Object see usage No Object to predefine an area to crop (an already detected image for example)
initialImage String Yes Base64 encoded image you want to be cropped
height Number Yes Height of the image (will probably disappear in the future
width Number Yes Width of the image (will probably disappear in the future
overlayColor String No Color of the cropping area overlay
overlayStrokeColor String No Color of the cropping area stroke
overlayStrokeWidth Number No Width of the cropping area stroke
handlerColor String No Color of the handlers
enablePanStrict Bool No Enable pan on X axis, and Y axis

Usage

import CustomCrop from 'react-native-perspective-image-cropper';

class CropView extends Component {
  componentWillMount() {
    const image = 'base64ImageString';
    Image.getSize(image, (width, height) => {
      this.setState({
        imageWidth: width,
        imageHeight: height,
        initialImage: image,
        rectangleCoordinates: {
          topLeft: { x: 10, y: 10 },
          topRight: { x: 10, y: 10 },
          bottomRight: { x: 10, y: 10 },
          bottomLeft: { x: 10, y: 10 },
        },
      });
    });
  }

  updateImage(image, newCoordinates) {
    this.setState({
      image,
      rectangleCoordinates: newCoordinates
    });
  }

  crop() {
    this.customCrop.crop();
  }

  render() {
    return (
      <View>
        <CustomCrop
          updateImage={this.updateImage.bind(this)}
          rectangleCoordinates={this.state.rectangleCoordinates}
          initialImage={this.state.initialImage}
          height={this.state.imageHeight}
          width={this.state.imageWidth}
          ref={(ref) => this.customCrop = ref}
          overlayColor="rgba(18,190,210, 1)"
          overlayStrokeColor="rgba(20,190,210, 1)"
          handlerColor="rgba(20,150,160, 1)"
          enablePanStrict={false}
        />
        <TouchableOpacity onPress={this.crop.bind(this)}>
          <Text>CROP IMAGE</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

Core symbols most depended-on inside this repo

Shape

Function 7
Method 5
Class 3

Languages

TypeScript53%
Java47%

Modules by API surface

index.js8 symbols
android/src/main/java/com/reactlibrary/RNCustomCropPackage.java4 symbols
android/src/main/java/com/reactlibrary/RNCustomCropModule.java3 symbols

For agents

$ claude mcp add react-native-perspective-image-cropper \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page