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.

209 questions
9
votes
7 answers

request formData to API, gets “Network Error” in axios while uploading image

I am making a POST request to server to upload an image and sending formdata using axios in react-native. i am getting "Network Error". i also try fetch but nothing work.using react native image picker libeary for select image.in postman api…
8
votes
0 answers

React-native node.js showing Error: Multipart: Boundary not found while uploading image using react-native-image-picker

While Uploading image , It is showing Error: Multipart: Boundary not found on node js server console here is my react native code const createFormData = async (photo, body) => { const data = new FormData(); …
7
votes
3 answers

TypeError: undefined is not an object (evaluating '_reactNativeImagePicker.default.showImagePicker')

Using React Image Picker i am facing this error: TypeError: undefined is not an object (evaluating '_reactNativeImagePicker.default.showImagePicker') This is what happens when i click on image picker function Mobile Screenshot: This is my…
MuhammadShahbaz
  • 103
  • 1
  • 7
7
votes
2 answers

react-native-image-picker vs expo ImagePicker

I have tried many attempts to get react-native-image-picker up and working with my RN app. I am using Expo and VS Code and am not running the app with Xcode or Android Studio. There seems to be many options to getting the camera roll available in an…
6
votes
2 answers

React-Native: Crashes on android when using openCamera using react-native-image-crop-picker and Camera in general

I've been having issues with react-native-image-picker and react-native-image-crop-picker while opening camera on my One Plus 6 for a while now. While using opening the camera, the background app that opened the camera (my app) crashes. It goes to a…
4
votes
1 answer

The module react-native-image-picker in iOS always requires microphone permissions although I don't select video, only camera

I'm using react-native-image-picker (to take photos / to select photos) to upload them to my server. It works perfectly. To do this I use an ImagePicker. The problem comes when I notice that in iOS, if I want to use it, the module requires me the…
SmoggeR_js
  • 2,431
  • 4
  • 14
  • 44
4
votes
1 answer

React-native-image-picker: How to access gallery images directly in grid fashion

I am using react-native-image-picker and I would like to access gallery images directly from the device. However, when I launch ImageLibrary using the following method, I would see further 2 options saying "Pictures", "Download". Instead I would…
Inaccessible
  • 1,434
  • 2
  • 16
  • 39
3
votes
2 answers

Trigger an event before the image shown on the screen?

I am trying to implement a triggering event before the image shown on the screen. The snippet below is working properly to pick an image and it's showing on the screen. After clicking the CROP the image is showing on the screen. However, After…
3
votes
0 answers

react-native-fs library is not moving or copying files - weird results

npmPackages: @react-native-community/cli: ^4.13.0 => 4.13.0 react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-windows: Not Found react-native-fs: ^2.16.6 react-native-image-picker: ^2.3.4 IDEs: …
3
votes
2 answers

react-native-image-picker not working in android 10

i am working with a project that i need to use the camera or choose image from Library so used react native image picker it works fine in develop mode and in production it doesn't work in Android 10 only i tried a lot of solutions from github like…
Hamza Elm
  • 115
  • 1
  • 8
3
votes
1 answer

Expo-Image-Picker in React Native

Is there a way to limit video recording time using ImagePicker.launchCameraAsync()? My code: captureVideoObject = async () => { return await ImagePicker.launchCameraAsync({ mediaTypes: ImagePicker.MediaTypeOptions.Videos, …
3
votes
0 answers

react-native-image-picker: value returned from showImagePicker doesnt tell you if user blocked permission (Android)

I want user to select a profile picture using either camera or photo gallery. I use react-native-image-picker to give user choice.....using below code: import ImagePicker from 'react-native-image-picker'; export const _imagePickHandler = userId =>…
3
votes
4 answers

How to send an image message only ? (without sending a text as well)

I simply want to send an image without typing any text ? I am using react-native-image-picker and i currently can send an image with a text , but what if i want to send an image only ? I tried alwaysShowSend and try to send but nothing happens…
3
votes
0 answers

React Native: Get Duration of local video

I am currently using react-native-image-picker to allow a user to select a video from their gallery. I am trying to disallow them from uploading a video that is greater than 'X' number of seconds. Is there anyway to programmatically retrieve the…
dmouawad
  • 319
  • 1
  • 2
  • 10
3
votes
4 answers

Convert Image to base64 in react native

I have used react-native-image-picker and now I select image from the Photo library. To send the that image to API I have to convert it first into base64 and then into byte array. I have the filepath in response.uri. How do I do it? When I did…
user11426267
  • 171
  • 4
  • 12
1
2 3
13 14