react-native-perspective-image-cropper icon indicating copy to clipboard operation
react-native-perspective-image-cropper copied to clipboard

Cropping not correct

Open armin23615 opened this issue 4 years ago • 12 comments

react-native: 0.60.5 react-native-perspective-image-cropper": "^0.4.4

Original: Screenshot_20200220-164834_Straight_Line 1

Selected coords: Screenshot_20200220-165037_Straight_Line 1

Result: Screenshot_20200220-165046_Straight_Line 1

constructor(props) {
    super(props)
    this.state = {
      enableExtract: false,
    }
    this.updateImage = this.updateImage.bind(this)
    this.crop = this.crop.bind(this)
  }

  componentDidMount() {
    let image = this.props.navigation.getParam('image')

    Image.getSize(image, (width, height) => {
      this.setState({
        imageWidth: width,
        imageHeight: height,
        initialImage: image,
        rectangleCoordinates: {
          topLeft: { x: 50, y: 50 },
          topRight: { x: 50, y: 50 },
          bottomRight: { x: 50, y: 50 },
          bottomLeft: { x: 50, y: 50 },
        }
      })
    })
  }

  updateImage(image, newCoordinates) {
    this.setState(
      {
        image,
        rectangleCoordinates: newCoordinates,
      },
      () => {
        this.props.navigation.navigate('CropResult', { cropImage: this.state.image })
      }
    )
  }

  crop() {
    this.customCrop.crop()
  }
<CustomCrop
              updateImage={this.updateImage}
              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}
            />

Any idea how to fix this?

armin23615 avatar Feb 20 '20 16:02 armin23615

I faced the same issue and since no one replied i tried to fix it myself and after many hours of trial and error i did managed to fix it and enhanced the usage, use this modified component for testing

react-native-perspective-image-cropper.zip

Make sure to change android/settings.gradle to point to the folder where you have pasted the component for e.g

include ':rreact-native-perspective-image-cropper' project(':react-native-perspective-image-cropper').projectDir = new File(rootProject.projectDir, '../src/components/react-native-document-scanner/android')

and change import statement to

import CustomCrop from "../../components/react-native-perspective-image-cropper"

If your issue is fixed as well, i can make a PR

maknom66 avatar Feb 25 '20 03:02 maknom66

Thank you so much, this works great! There is just one line in index.js -> import Exif from 'react-native-exif' It's not used anywhere and it prevents building app if 'react-native-exif' package isn't installed.

armin23615 avatar Feb 25 '20 10:02 armin23615

Thank you so much, this works great! There is just one line in index.js -> import Exif from 'react-native-exif' It's not used anywhere and it prevents building app if 'react-native-exif' package isn't installed.

Oops, my bad, i was just tinkering with exif to see if it helps and forgot to remove it, glad that it worked though :)

maknom66 avatar Feb 25 '20 18:02 maknom66

@maknom66 IOS still same issue please help.

hashimkhatri avatar Mar 29 '20 18:03 hashimkhatri

can any one can send source code ?

Ahmad5448 avatar Jun 02 '20 16:06 Ahmad5448

source code for only file where u used this component

Ahmad5448 avatar Jun 02 '20 16:06 Ahmad5448

thankyou so so much @maknom66 .

ambessh avatar Sep 03 '20 08:09 ambessh

@maknom66 Did you manage to resolve this issue on iOS? Your version works really well on Android but as @hashimkhatri mentioned it is not cropping correctly on iOS.

rosentoshev avatar Oct 01 '20 12:10 rosentoshev

@maknom66 Thanks so much for the fix! If you have time please make a PR. I would like to avoid manual inclusion of the resources if possible.

ssudekum avatar Dec 10 '20 20:12 ssudekum

ould like to avoid

@maknom66 In android working fine, Having issue in iOS after capturing image from camera, While picking image from gallery in that scenario it's working fine.

++ @Michaelvilleneuve

NTJ3 avatar Mar 28 '22 05:03 NTJ3

please see my PR #64

cdcharlebois avatar Jul 14 '22 12:07 cdcharlebois

I faced the same issue and since no one replied i tried to fix it myself and after many hours of trial and error i did managed to fix it and enhanced the usage, use this modified component for testing

react-native-perspective-image-cropper.zip

Make sure to change android/settings.gradle to point to the folder where you have pasted the component for e.g

include ':rreact-native-perspective-image-cropper' project(':react-native-perspective-image-cropper').projectDir = new File(rootProject.projectDir, '../src/components/react-native-document-scanner/android')

and change import statement to

import CustomCrop from "../../components/react-native-perspective-image-cropper"

If your issue is fixed as well, i can make a PR

Thank You you save my day

Charitrajadon avatar May 05 '23 14:05 Charitrajadon