0

I am trying to get EXIF Metadata informations before capturing Image. I am using React Native Camera library for implementing camera and their properties for defaults settings. In my point of view after capturing only i am getting EXIF metadata value in both Android and iOS. React native camera documentation link.

 render() {
    return (
        <View style={{ backgroundColor: 'transparent', flex: 1 }}>
            <View style={styles.MainContainer}>
                <StatusBar barStyle='light-content'></StatusBar>
                <View style={[styles.TitleView]}>
                    <Text style={styles.title}>Camera</Text>
                </View>
                <View style={{

                    flexDirection: 'column',
                    justifyContent: 'center',
                    backgroundColor: 'transparent',
                    marginBottom: 20,
                }}>
                <RNCamera
                    ref={ref => {
                        this.camera = ref;
                    }}
                    onBarCodeRead={(code) => {
                        console.log('bar', code)
                      // if (this.state.barcode === '') this._onBarcodeRead(code)
                      }}

                    style={styles.preview}
                    type={RNCamera.Constants.Type.back}
                    flashMode={RNCamera.Constants.FlashMode.off}
                    whiteBalance={RNCamera.Constants.WhiteBalance.auto}
                    autoFocus={RNCamera.Constants.AutoFocus.on}
                    autoFocusPointOfInterest={ {x: 0.5, y: 0.5 }}
                    exposure={0.5}
                    focusDepth={1.0}
                    cameraViewDimensions={{
                        width: CAM_VIEW_WIDTH,
                        height: CAM_VIEW_HEIGHT,
                    }}

                    showViewFinder={true}
                    androidCameraPermissionOptions={{
                        title: 'Permission to use camera',
                        message: 'We need your permission to use your camera',
                        buttonPositive: 'Ok',
                        buttonNegative: 'Cancel',
                    }}
                    androidRecordAudioPermissionOptions={{
                        title: 'Permission to use audio recording',
                        message: 'We need your permission to use your audio',
                        buttonPositive: 'Ok',
                        buttonNegative: 'Cancel',
                    }}
                    onGoogleVisionBarcodesDetected={({ barcodes }) => {
                        console.log(barcodes);
                    }}
                >
                    {/* <View
                    style={{
                    // position: 'absolute',
                    // top: 20,
                    // right: 20,
                    alignSelf: 'center',
                    justifyContent: 'center',
                    width: frameHeight,
                    height: frameWidth,
                    borderWidth: 2,
                    borderColor: 'white',
                    opacity: 0.5,
                    }}
                /> */}
                    <View style={{ flexDirection: 'row', justifyContent: 'center', }}>
                        <TouchableOpacity onPress={this.takePicture.bind(this)} style={styles.capture}>
                            <Text style={{ fontSize: 14 }}> Click </Text>
                        </TouchableOpacity>
                    </View></RNCamera></View>
                <View style={{ backgroundColor: 'red' }}>
                    <Text>Back camera: {RNCamera.Constants.Type.back}</Text>
                    <Text>autoFocusPointOfInterest</Text>
                </View>



            </View>
        </View>
    )
}
}



takePicture = async () => {
        if (this.camera) {
            const options = { quality: 0.5, base64: true, exif: true };
            this.setState({loading: true})
            const data = await this.camera.takePictureAsync(options);
            console.log(data); // This data provide EXIF data
        }
    };

In Native iOS we get live metadata using CMSampleBuffer delegate. Is there any possibility to get Exif data before taking pictures.

Sreejith S
  • 376
  • 2
  • 12
  • Exif meta data is data stored in jpg files. So how would you get that data if the file does not even exist? I think you have to rewrite what you want. – blackapps Jun 08 '20 at 09:04

0 Answers0