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

onImageCrop is not returning anything in Android. #63

Open
shahanshah87 opened this issue Feb 8, 2022 · 2 comments
Open

onImageCrop is not returning anything in Android. #63

shahanshah87 opened this issue Feb 8, 2022 · 2 comments

Comments

@shahanshah87
Copy link

shahanshah87 commented Feb 8, 2022

I am trying after copying the example code and it is working fine in iOS but not working in Android. I am using this to pick image.

`import React, { useState, useRef } from 'react';
import { Button, StatusBar, StyleSheet, View, Image } from 'react-native';
import { CropView } from 'react-native-image-crop-tools';
import { launchCamera, launchImageLibrary } from 'react-native-image-picker';

const App = () => {
const [uri, setUri] = useState();
const cropViewRef = useRef();
return (
<>


<View style={{ backgroundColor: "red" }}>
<Button
title={'Pick Image'}
onPress={() => {
const options = {
mediaType: "photo"
}
launchImageLibrary(options, (response) => {
setUri(response.uri);
})
}}
/>

{uri !== undefined && <CropView
sourceUrl={uri}
style={styles.cropView}
ref={cropViewRef}
onImageCrop={(res) => alert(JSON.stringify(res))}
keepAspectRatio
aspectRatio={{ width: 16, height: 9 }}
/>}
<View style={{ backgroundColor: "red4" }}>

                <Button
                    title={'Get Cropped View'}
                    onPress={() => {
                        cropViewRef.current.saveImage(90);
                    }}
                />
            </View>
        </View>
    </>
);

};

const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 40
},
cropView: {
flex: 1,
backgroundColor: 'red'
},
});

export default App;`

@geakk
Copy link

geakk commented Mar 27, 2022

got the same problem...

@jonmajorc
Copy link

Hey! When you usesaveImage make sure to pass both arguments saveImage(true, 90);

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

3 participants