Open shahanshah87 opened 2 years ago
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={styles.container}> <View style={{ backgroundColor: "red" }}> <Button title={'Pick Image'} onPress={() => { const options = { mediaType: "photo" } launchImageLibrary(options, (response) => { setUri(response.uri); }) }} /> </View> {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;`
got the same problem...
Hey! When you usesaveImage make sure to pass both arguments saveImage(true, 90);
saveImage
saveImage(true, 90);
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 ( <>
};
const styles = StyleSheet.create({ container: { flex: 1, marginTop: 40 }, cropView: { flex: 1, backgroundColor: 'red' }, });
export default App;`