react-native-image-picker: [πŸ›] Error processing request body: Could not find image file

Description

Error when trying to upload image from gallery

Simulator Screen Shot - iPhone 12 - 2023-04-20 at 13 10 32

Running the example app of this repo gives me the same issue:

https://user-images.githubusercontent.com/2533919/233574721-ce717d9a-9a00-4f30-b912-483a18f16afd.mp4

How to repeat issue and example

const imagePickerDefaultOptions = {
  selectionLimit: 0,
  mediaType: 'photo' as MediaType,
  includeBase64: false,
  includeExtra: true,
};

launchImageLibrary(imagePickerDefaultOptions, (imgPickerResponse) => {
    if (imgPickerResponse.assets?.[0]) {
      onPhotoTaken(imgPickerResponse.assets?.[0]);
    }
  });

Solution

What needs to be done to address this issue?

Additional Information

  • Image Picker version: >=4.10.3
  • React Native version: 0.66.1 and 0.71.2
  • Platform: iOS
  • Development Operating System: MacOS
  • Dev tools: Xcode 14.0.1, iOS 16.0

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 6
  • Comments: 27

Most upvoted comments

Seems to only happen for me on the sim flower image (the one picked in the video above), which is marked as HDR and has image type of HEIC when viewed in the photos app

@dmsierra11 I believe the problem is here.

Successfully selected image:

{
  "fileName":"5693202E-E952-4C0D-A69B-2FF9B0F6C688.jpg",
  "fileSize":993045,
  "height":2500,
  "type":"image/jpg",
  "uri":"file:///Users/mayderson/Library/Developer/CoreSimulator/Devices/D555E641-C03B-407D-9251-28DBEF5BFEE6/data/Containers/Data/Application/D641C420-4AE4-49AB-A63B-5B05E88F59D7/tmp/5693202E-E952-4C0D-A69B-2FF9B0F6C688.jpg",
  "width":1668
}

Error selected image:

{
  "fileName":"B22A70A5-D144-4857-8249-97C1FDB3FAE1.jpg",
  "height":0,
  "type":"image/jpg",
  "uri":"file:///Users/mayderson/Library/Developer/CoreSimulator/Devices/D555E641-C03B-407D-9251-28DBEF5BFEE6/data/Containers/Data/Application/D641C420-4AE4-49AB-A63B-5B05E88F59D7/tmp/B22A70A5-D144-4857-8249-97C1FDB3FAE1.jpg",
  "width":0
}

In other words, the height and width attributes are coming with 0 and the fileSize is not coming, which is causing this problem.

same issue on "react-native-image-picker": "^7.0.0",

Use react-native-image-crop-picker

I had a similar encounter with a captivating sunflower image. If anyone else has experienced this issue with different images, I would greatly appreciate it if you could kindly share your observations.

I had the same issue I believe its crashing for the image which are not available like the one that are on cloud. Once the cloud image is downloaded it does not crash.

Looking at @samcodefish PR and from my understanding of the problem, it seems that .heic files cannot be handled like .jpg files. When selecting a .heic file, the copy that you can access from launchImageLibrary response is a .jpg file (at least it is what I find in uri property) and that is why height, width, type and fileSize are wrong and you can’t access it.

Unfortunately, your PR does not correct this behavior, I still got uri to a .jpg file that result in a bug (β€œCould not find image …”)

I just want to add that to get to this conclusion, I only used the .heic image from the iPhone 12 mini - iOS 16.2 emulator, the one that display flowers. Maybe it is different with a real device or with different images

EDIT: It seems that

It’s a known issue that the red flower image can’t be selected using the simulator

I tried with an other heic file and it works fine (on simulator). Thanks Apple I guess πŸ˜’

(source https://developer.apple.com/forums/thread/699155?answerId=702819022#702819022)

I had a similar encounter with a captivating sunflower image. If anyone else has experienced this issue with different images, I would greatly appreciate it if you could kindly share your observations.