react-native-image-resizer
react-native-image-resizer copied to clipboard
Unable to load source image from path
on android platfrom Unable to load source image from path
I got this issue too.
Can you post the full stackstrace of the error?
Can you also console.log the path of the image?
I have fixed this, i got this error because i pass the file path which is lead to nothing.
Same problem. But i am sure that i passed the current image uri to the createResizedImage(...)
same problem, works in ios and not works in android
same issue. Image is present. Other images in same path have been uploaded but not this particular image.
RNFS.readFile(ap[1], 'base64') this code successfully reads the file but createResizedImage is not able to
Even passing in base 64 format does not help
"data:image/jpeg;base64,"+imageBase64
For the android, you must use base64 then use RNFS to create new image based on the base64.
Try this:
response = async (result) => {
let path = result.uri || result.path;
if (Platform.OS === 'android') {
let newFilePath = `${RNFetchBlob.fs.dirs.CacheDir}/${path.substring(path.lastIndexOf('/') + 1)}`;
let newFile = await RNFetchBlob.fs.writeFile(`${RNFetchBlob.fs.dirs.CacheDir}/${path.substring(path.lastIndexOf('/') + 1)}`,
result.base64,
'base64');
path = newFilePath;
}
if (/^\/private/.test(path)) {
path = path.substring(8);
}
if (!/^file:/.test(path)) {
path = `file://${path}`;
}
return {
height: result.height,
width: result.width,
isVertical: true,
cancelled: false,
uri: path,
fileSize: result.size,
mime: result.mime,
data: result.data
};
};
action = async (type) => {
let result;
let options = {
cropping: true,
allowsEditing: true,
aspect: [1, 1],
base64: Platform.OS === 'android'
};
switch (type) {
case 1:
result = await ImagePicker.openCamera(options);
break;
case 2:
result = await ImagePicker.openPicker(options);
break;
}
if (result && !result.cancelled) {
return await this.response(result);
}
return null;
};
Getting the same error in android: Unable to load source image from path Any update on this? @PierreCapo @robertbarclay @JimTeva
It could be a scoped storage issue. I solved it by adding:android:requestLegacyExternalStorage="true" to my AndroidManifest, inside the application tag.
Note that this is a temporary workaround and may not work for Android 11 (API level 30) and beyond.
This error also could be thrown if data schema is not compatible with android impl. In my case I had to fix "Unable to load source image from path" Android while iOS was working perfectly. The cause was misspelling: data:image/jpg;base64,${base64Image} was used instead of data:image/jpeg;base64,${base64Image} (note jpg vs jpeg). Plugin's native android part requires strict scheme while iOS not.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed. Thank you for your contributions.