npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-custom-crop

v0.1.0

Published

React native library allowing you to make custom crop and perspective corrections on photos

Downloads

2

Readme

React Native Custom Crop 📐🖼

A component that allows you to perform custom 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-custom-crop --save

$ react-native link react-native-custom-crop

This library uses react-native-svg, you must link its content too.

$ react-native link react-native-custom-crop/node_modules/react-native-svg

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 |

Usage

import CustomCrop from 'react-native-custom-crop';

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)"
        />
        <TouchableOpacity onPress={this.crop.bind(this)}>
          <Text>CROP IMAGE</Text>
        </TouchableOpacity>
      </View>
    );
  }
}