I am trying to implement a function in my application, where the user can select an image from the list of their cameras, and the application will decode the QR code in the detected image.
I am currently using a react camera selector: https://github.com/jeanpan/react-native-camera-roll-picker and response-native-qrcode-local-image: https://github.com/remobile/ react-native-qrcode-local-image
The problem is that the local QR code image library requires me to skip the local path and is not compatible with the native URI provided by the responsive camera selector. I would use another library to decode the QR code of the image, but this one seems to be the only one that works on iOS and Android and scans existing images, not a real camera.
I also tried implementing response-native-fetch-blob to temporarily save the camera image, but that also caused me problems: https://github.com/wkh237/react-native-fetch-blob
This is my current attempt in a function that I call in the "callback" support for the response-native-camera-roll-picker command (with previous attempts commented out):
_pickedImage(array,currentImg) { console.log(currentImg) var path = RNFS.DocumentDirectoryPath + '/pickedqr'; let rnfbURI = RNFetchBlob.wrap(RNFetchBlob.fs.asset(currentImg.uri)) const Blob = RNFetchBlob.polyfill.Blob Blob.build(rnfbURI, {type:'image/jpg'}).then((b) => { tmpBlob = b; RNFetchBlob.fs.readFile(tmpBlob, 'base64').then((data) => { console.log("Base64", data) QRDecoder.decode('data:image/gif;base64,${data}', (error, result)=>{ console.log("Code", result) console.log("Error", error) }); }); }) /*fullPath = currentImg.uri.replace("assets-library://", "cdvfile://localhost/assets-library/") QRDecoder.decode(fullPath, (error, result)=>{ console.log("Code", result) console.log("Error", error) });*/ /*let blb = Blob.build( rnfbURI, { type: 'image/jpg'}) console.log(blb)*/ /*RNFetchBlob.fs.readFile(rnfbURI, 'base64').then((data) => { console.log("Base64", data) QRDecoder.decode('data:image/gif;base64,${data}', (error, result)=>{ console.log("Code", result) console.log("Error", error) }); })*/ }
At the moment, I am completely at a loss, so any methods or understanding will be highly appreciated.