Questions tagged [react-native-image-picker]

This package is the basic package by react native community to upload an image from your gallery or camera.

This is the way it opens on click in iOS

This way it opens in android on a click

A React Native module that allows you to use native UI to select a photo/video from the device library or directly from the camera. You have to specify both permission of accessing camera and gallery in both platforms(android and iOS).

A code snippet to simplify:

import ImagePicker from 'react-native-image-picker';

// More info on all the options is below in the API Reference... just some common use cases shown here
const options = {
  title: 'Select Avatar',
  customButtons: [{ name: 'fb', title: 'Choose Photo from Facebook' }],
  storageOptions: {
    skipBackup: true,
    path: 'images',
  },
};

/**
 * The first arg is the options object for customization (it can also be null or omitted for default options),
 * The second arg is the callback which sends object: response (more info in the API Reference)
 */
ImagePicker.showImagePicker(options, (response) => {
  console.log('Response = ', response);

  if (response.didCancel) {
    console.log('User cancelled image picker');
  } else if (response.error) {
    console.log('ImagePicker Error: ', response.error);
  } else if (response.customButton) {
    console.log('User tapped custom button: ', response.customButton);
  } else {
    const source = { uri: response.uri };

    // You can also display the image using data:
    // const source = { uri: 'data:image/jpeg;base64,' + response.data };

    this.setState({
      avatarSource: source,
    });
  }
});

Then later, you can display this image in your render() method.

304 questions
1
vote
1 answer

add a viw on top of camera opened by expo Image picker on react native expo application

I am currently using react native image picker library to open camera , and I would like to add a message in the form of a snack bar or a toast message on top of the opened camera using the following function: let result = await…
NQQ
  • 51
  • 1
  • 5
1
vote
1 answer

how to append the image the user has taken from ImagePicker.launchCameraAsync() to a FormData

I am trying to append the photo taken by the user from ImagePicker.launchCameraAsync() I need to send the file itself not a base64 version of it and I am using expo with react native so react-native-fs doesn't work with me I can get the path of the…
1
vote
1 answer

Difficulties handling asynchronous taks using image-picker and copying files in react-native

The following component CapturePhoto is used to take a photo using react-native Image Picker, once a photo is taken, I copy the photo file to a specific path that I pass as prop to this component from its parent ( a gallery of images that is a list…
1
vote
1 answer

React Native Expo - how to get local uri to user's media library from image picker

I can't find how one would get (using expo packages) the local uri like file:///storage/emulated/0/DCIM/Camera/... from user picking an image from their media library without having to re-save/duplicate the image. This gives me a paginated structure…
jave.web
  • 13,880
  • 12
  • 91
  • 125
1
vote
1 answer

Cancelling/Exiting Photo Library in Android using react-native-image-crop-picker

In my React Native app, I use the react-native-image-crop-picker package to have access to user's photo library. It works nicely but if the user has no images in his/her photo library, I want to give the user a way to cancel out or exit it. How do I…
1
vote
1 answer

In newer iOS versions, error using form-data w/ multer & react-native-image-picker ([_NSCFConstantString substringToIndex:]: Index x out of bounds...)

When trying to send form-data that includes an image to the node multer library in the backend, the iOS simulators are giving me the error below in newer ios versions (version 13.7 didn't have any issue sending the image): Exception '***…
1
vote
0 answers

React Native Expo-Image-Picker base64 too slowly

I'm saving pictures with the help of expo image picker and axios, but the base64 storage part in the database is very long and naturally it takes a long time to load when listing the images on a screen. What can I do to make images load…
yasin
  • 27
  • 1
  • 7
1
vote
1 answer

Image-picker not displaying the result photo react-native

I'm learning to code in react-native, I'm using in this code the library Image-picker for taking photos or loading images from gallery. When I take a photo, the image view is set with a blank white image! Can someone review this code (I followed a…
sarli
  • 23
  • 5
1
vote
1 answer

React Native Expo ImagePicker - Getting undefined image.uri the first time but saving ok the second time

I have a function to take a photo with android, with Expo-Image-Picker. I save the result in a local state pickedUri, then sending it to Redux state through dispatch. The first time I get pickedUri as undefined, but the second time it saves the…
1
vote
1 answer

Image is not shown after image is selected from react-native image-picker

I am developing an application in which i need to upload an image from phone camera and also from gallery . camera & gallery is not showing image inside image tag. here is my code function profile({ route,navigation }) { const [imageUri,…
vainu
  • 131
  • 1
  • 12
1
vote
0 answers

react-native-image-crop-picker restarting application on Redmi Android 11 on wide mode of openCamera

I am trying to use react-native-image-crop-picker but only on Redmi Phones with Android 11. It is restarting the application when an image is selected from openCamera functionality with wide mode only (normal camera click works), the Application…
1
vote
1 answer

react native image uri and async storage

i'm trying to save a profile picture and i save it with asyncStorage. store part working perfectly but if i close app and reopen it doesn`t show image. i logging image uri and there is uri but cant solve the problem. here is my code this is image…
1
vote
1 answer

React Native - Opening Android Image Gallery Directly

As the title states, I am wondering how to open the Android image gallery directly from my app. Every single package that is out there, including react-native-image-picker, react-native-image-crop-picker, and yes, even Expo's expo-image-picker all…
1
vote
3 answers

How to upload large files using react-native-image-crop-picker

I'm trying to upload small files using react-native-image-crop-picker it's working fine but when I tried uploading large video/image file using react-native-image-crop-picker I'm getting Network error. Note : Backend is working fine I'm able to…
1
vote
1 answer

React native [TypeError: undefined is not an object (evaluating 'iter[Symbol.iterator]')] error

So I have a an image selector that when I press, it launches the phone image library and then when I select the image it is supposed to fill that image selector but every time i select an image, I get this error [TypeError: undefined is not an…
Vuyi
  • 96
  • 3
  • 14