react-native-image-crop-picker
react-native-image-crop-picker copied to clipboard
Android only: "Cannot find image data" crashes on webp images
Version
Tell us which versions you are using:
- react-native-image-crop-picker v0.32.2
- react-native v0.62.0
Platform
Issue only happens on Android, iOS working as expected.
Expected behaviour
When selecting an image from openPicker it should return without error
Actual behaviour
After calling ImagePicker.openPicker and selecting the image, it gives below error
Cannot find image data
at Object.promiseMethodWrapper [as openPicker] (NativeModules.js:103)
at HomeScreen.loadImageGallery (homescreen.js:107)
at Object.onPress (homescreen.js:75)
at onAction (Alert.js:92)
at MessageQueue.__invokeCallback (MessageQueue.js:472)
at MessageQueue.js:136
at MessageQueue.__guard (MessageQueue.js:373)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:135)
at RNDebuggerWorker.js:2
Steps to reproduce
-
Install module
-
Run this code
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: true,
}).then(image => {
console.log(image);
}).catch(e => console.log('er', e));
Attachments
I have added android:requestLegacyExternalStorage="true" so my manifest looks like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.isofit">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
My build script is
buildToolsVersion = "29.0.3"
minSdkVersion = 16
compileSdkVersion = 29 //28
targetSdkVersion = 29
Any help is greatly appreciated, thank you.
EDIT: It turns out that this only happens when a *.webp image is selected on Android, I'm happy to exclude them but there is no way to prevent the user from selecting a webp image so the app continues to crash unexpectedly.
How did you solve it? How can I exclude *.webp images?
I haven't solved it. The issue still exists.
and will be... because of https://github.com/Yalantis/uCrop/issues/166#issuecomment-245606245 and https://github.com/Yalantis/uCrop/issues/624
A possible workaround is to call openPicker or openCamera without the cropping enabled and to then call openCropper with the picked image, since this library already converted it at that point.
A possible workaround is to call openPicker or openCamera without the cropping enabled and to then call openCropper with the picked image, since this library already converted it at that point.
really works,this helped a lot, thanks
I have the same error, the application crashes when the user chooses a .webp image.
A possible workaround is to call openPicker or openCamera without the cropping enabled and to then call openCropper with the picked image, since this library already converted it at that point.
perfect solution, thanks very much. I fixed the samilar bug "cannot find image data" on xiaomi、HONOR device when selecting some pic to crop by the way ImagePicker.openPicker({ cropping: true... })
.
use as below
let selectedImage = await ImagePicker.openPicker({
mediaType: "photo",
cropping: false,
});
console.log('selectedImage:::', selectedImage);
let croppedImage = await ImagePicker.openCropper({
path: selectedImage.path,
width: props.width,
height: props.height,
})
console.log('croppedImage:::', croppedImage);
A possible workaround is to call openPicker or openCamera without the cropping enabled and to then call openCropper with the picked image, since this library already converted it at that point.
perfect solution, thanks very much. I fixed the samilar bug "cannot find image data" on xiaomi、HONOR device when selecting some pic to crop by the way
ImagePicker.openPicker({ cropping: true... })
.use as below
let selectedImage = await ImagePicker.openPicker({ mediaType: "photo", cropping: false, }); console.log('selectedImage:::', selectedImage); let croppedImage = await ImagePicker.openCropper({ path: selectedImage.path, width: props.width, height: props.height, }) console.log('croppedImage:::', croppedImage);
what if i opening shared image directly to openCropper??
A possible workaround is to call openPicker or openCamera without the cropping enabled and to then call openCropper with the picked image, since this library already converted it at that point.
perfect solution, thanks very much. I fixed the samilar bug "cannot find image data" on xiaomi、HONOR device when selecting some pic to crop by the way
ImagePicker.openPicker({ cropping: true... })
. use as belowlet selectedImage = await ImagePicker.openPicker({ mediaType: "photo", cropping: false, }); console.log('selectedImage:::', selectedImage); let croppedImage = await ImagePicker.openCropper({ path: selectedImage.path, width: props.width, height: props.height, }) console.log('croppedImage:::', croppedImage);
what if i opening shared image directly to openCropper??
Thanks you very much. you have saved me.