ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.16k stars 1.56k forks source link

Getting "Cannot find image data" and "code":"E_NO_IMAGE_DATA_FOUND #1538

Open ghost opened 3 years ago

ghost commented 3 years ago

An error message is r returned when tried to upload an image from gallery, which is in .heic format.

Error log

Version

Platform

Expected behaviour

Return the image selected from gallery

Actual behaviour

Throws 'E_NO_IMAGE_DATA_FOUND '

Steps to reproduce

1.Open image from gallery (.heic format)

I found forceJpg prop can be used in iOS. Is there any solution or any way to convert .heic files to compatible format in android ? Thanks in advance

ghoshabhi commented 3 years ago

bump :)

ali226281 commented 3 years ago

Is there no solution?

HugoGresse commented 3 years ago

I think I have a solution. I'm not sure it is the right issue though, as in my cases, the images where not .heic and the issue comes from requireLegacyExternalStorage to be removed from the manifest. The issue is the permission denied (eaccess) for the BitmapFactory to decode the file. The path return by RealPathUtil is correct but does not grant any read/write possibility, thus we need to copy the file. I've taken the code from the Flutter (yes Flutter) image_picker following this issue and this PR with up to date change from today. It is only for images, so usage may vary but you should be able to adapt it easily.

Here is the patch file to be applied using npm patch package:

react-native-image-crop-picker+0.36.2.patch.zip

Based on the discussion from Flutter repo, the RealPath utils could probably be re-written totally using this with some minor adaptation for video.

BrieMac commented 3 years ago

I was experiencing the issue that @HugoGresse describes and the patch package seems to have fixed it! 🌟 Thank you.

I was getting E_NO_IMAGE_DATA_FOUND when calling openPicker and selecting images from the gallery but was able to successfully select the same image when it was stored on the device itself.

Originally I thought that the issue was the .heic format but I think that may have been a red herring in my case with the actual issue being the location of the image.

I am now able to select .heic files from the device and the image picker seems to be converting them to jpgs which is acceptable behaviour for my use case.

ali226281 commented 3 years ago

when I try crop an image in .heic format (using ImagePicker.openCropper) returned error (Error: Cannot find image data)

Version react-native-image-crop-picker v0.34.1 react-native v0.63.0

Platform Android

Is there any solution ?

sonnguyen2000-github commented 2 years ago

make sure you set cropping = false when mediaType is 'video'

tommynordli commented 2 years ago

+1 for this. Even though .heic is an Apple format, Android phones are still able to read it. Would be great to add support for .heic on Android, but would also help a lot just catching the error avoiding a crash.

camboYY commented 2 years ago

+1 for this. Even though .heic is an Apple format, Android phones are still able to read it. Would be great to add support for .heic on Android, but would also help a lot just catching the error avoiding a crash.

i face this issue Error: Cannot find image data