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
19
votes
7 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
  • 247
  • 2
  • 3
  • 9
14
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…
Olivia
  • 1,843
  • 3
  • 27
  • 48
13
votes
18 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…
11
votes
2 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(); …
10
votes
1 answer

Task :react-native-image-picker:compileDebugJavaWithJavac FAILED

i have a project that i was giving to update the UI , but anytime I run the app with npx react-native run android it gives the error Task :react-native-image-picker:compileDebugJavaWithJavac FAILED this is the full error below: `Deprecated Gradle…
10
votes
1 answer

React Native app crash when returning from camera on Android

I have a problem that seems to be pretty common, but I haven't found a solution yet. I'm using react-navigation, react-native-screens and react-native-image-picker. That last plugin allows the app to take photos and load photos from gallery. It…
9
votes
4 answers

NativeFirebaseError: [storage/unauthorized] User is not authorized to perform the desired action

I'm having problems uploading an image to Firebase Storage. I'm using React Native's @react-native-firebase/storage and the installation and connectivity seem to be fine because I'm able to reference images just fine: const ref =…
6
votes
4 answers

React Native Task :react-native-image-picker:compileDebugJavaWithJavac FAILED

When trying to run my project on my windows computer it is not working, it works on my macOS but when running it on windows it throws the following errors: Task :react-native-image-picker:compileDebugJavaWithJavac FAILED if (Build.VERSION.SDK_INT <…
6
votes
6 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
  • 361
  • 4
  • 7
  • 13
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…
Rimoch
  • 103
  • 1
  • 6
6
votes
2 answers

react-native-image-picker reducing the size of the file and quality

I want to maintain the quality(size) of the image being uploaded. The options being used for this is const options = { quality:1, maxWidth: 500, maxHeight: 500, allowsEditing: false, storageOptions: { skipBackup: true } }
Prakash
  • 396
  • 1
  • 6
  • 23
5
votes
4 answers

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

I'm using "react-native-image-picker": "^3.0.1" in react native for capture image. but I got error while opening the camera in android 9. I got error : {"errorCode": "others", "errorMessage": "This library does not require…
Akshay I
  • 3,675
  • 1
  • 34
  • 57
5
votes
4 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…
user11583965
5
votes
1 answer

How to convert base64 to bytes in Expo React Native?

I'm trying to send image from image-picker to the server, but image-picker returns only base64. How can I convert base64 to bytes in React-Native using expo?
Jake_3H
  • 372
  • 4
  • 14
5
votes
4 answers

React Native Image Picker: null is not an object (evaluating 'ImagePickerManager.showImagePicker')

I installed react-native-image-picker according to the documentation. When I am trying to select the image from the phone (after hitting the button), the emulator is giving me this error- null is not an object (evaluating…
Iffat
  • 1,606
  • 4
  • 19
  • 33
1
2 3
20 21