1
因此,我使用react-native-signature-capture來捕獲簽名,但我不想在編碼之前減少圖像大小。我用https://github.com/bamlab/react-native-image-resizer調整圖像大小,但現在我不知道如何將其轉換爲base64。我嘗試使用RN的ImageStore,但是我得到了圖像文件路徑的錯誤。見下面的代碼:React Native - 調整圖像大小並將其轉換爲base64
ImageResizer.createResizedImage(encoded.pathName, 200, 100, 'PNG', 80, null, encoded.pathName)
.then((resizedImageUrl) => {
ImageStore.getBase64ForTag(resizedImageUrl, (data) => {
console.log(data);
}, (err) => console.log(err));
})
.catch((err) => console.log('failed to resize: ' + err));