Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cropping not correct #37

Open
armin23615 opened this issue Feb 20, 2020 · 12 comments
Open

Cropping not correct #37

armin23615 opened this issue Feb 20, 2020 · 12 comments

Comments

@armin23615
Copy link

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?

@maknom66
Copy link

maknom66 commented Feb 25, 2020

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

@armin23615
Copy link
Author

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.

@maknom66
Copy link

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 :)

@hashimkhatri
Copy link

@maknom66
IOS still same issue please help.

@Ahmad5448
Copy link

can any one can send source code ?

@Ahmad5448
Copy link

source code for only file where u used this component

@ambessh
Copy link

ambessh commented Sep 3, 2020

thankyou so so much @maknom66 .

@rosentoshev
Copy link

@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.

@ssudekum
Copy link

@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.

meliodev added a commit to meliodev/Synergys that referenced this issue May 5, 2021
Using a variant of react-native-perspective-image-cropper:
Michaelvilleneuve/react-native-perspective-image-cropper#37
C:\Users\lyous\OneDrive\Desktop\Github\Custom-Modules\react-native-perspective-image-cropper
@NTJ3
Copy link

NTJ3 commented Mar 28, 2022

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

@cdcharlebois
Copy link

please see my PR #64

@Charitrajadon
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants