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

Image is showing extremely slow when selecting from ImagePicker

I have not been able to figure out what might be the problem on why after selecting an image it takes 1-3 seconds just to show the picture. The array of images will have no more than 4 images. I use useState with an array in order to hold all the…
Jake
  • 462
  • 1
  • 5
  • 13
1
vote
2 answers

Undefined is not an object (evaluating 'response.assets[0]') React Native react-native-image-picker

I used react-native-image-picker; import { launchImageLibrary } from 'react-native-image-picker'; And when I top add img, but close window I had a error TypeError: undefined is not an object (evaluating 'response.assets[0]') My…
Nik Silver
  • 11
  • 2
1
vote
1 answer

React Native Customized Image Picker doesn't show gallery images on android

I have to use a multiple picker in my react native application, and I tried to use this package: react native customized image picker with the next configuration: ImagePicker.openPicker({ multiple: true }).then(images => { …
poPaTheGuru
  • 1,009
  • 1
  • 13
  • 35
1
vote
1 answer

React native No permission needed for camera or photo library access

I am working on an app where the user needs to load images from a photo library or camera, I am using the react-native-image-picker library for accessing the camera, however, I use it without react-native-permissions and it still works. I know it's…
1
vote
2 answers

React Native: Console Warning Possible Unhandled Promise Rejection (id:0): TypeError: Cannot read property 'uri' of null

I am following this tutorial on uploading photos to Firebase in React Native and have it all set up using 'react-native-image-picker' and 'launchImageLibrary' (instead of the 'showImagePicker' in the tutorial as it is no longer in use). However,…
1
vote
0 answers

How to upload image in React Native with NodeJs?

This is my frontend: import React from 'react'; import {StyleSheet, Text, View, TouchableHighlight } from 'react-native'; import {launchImageLibrary} from 'react-native-image-picker'; const App = () => { const [photo, setPhoto] =…
1
vote
1 answer

ImagePicker not showing selected image

I'm using the launchImageLibrary function from the react-native-image-picker library. I am able to to select images from my library but the selected image doesn't show up on my app but its shows that the uri has changed in the console. Here's a…
1
vote
1 answer

Can't pick any document/image in react native (ANDROID 11)

I cant pick any files from storage to app, upon picking it crashes the app getting permission denied in logcat tho I have added these permissions in manifest.
1
vote
2 answers

What to use instead of ImagePicker.showImagePicker?

ImagePicker.showImagePicker was removed from the ImagePicker. You can now either launchCamera or launchImageLibrary. What will be the best alternative to allow the user to do both (Camera or Library)? Edit: I am looking for a library that would…
AYBABTU
  • 986
  • 3
  • 17
  • 39
1
vote
0 answers

Image crop picker save images to gallery on click from camera in react native

Hi I am using react native image crop picker and using this code ImagePicker.openCamera({ width: 300, height: 400, compressImageQuality: Platform.OS === 'android' ? 0.7 : 0.8, cropping: false, // includeBase64: true, …
Rover
  • 661
  • 2
  • 18
  • 39
1
vote
0 answers

Failed to allocate a 14745612 byte allocation with 7913456 free bytes and 7MB until OOM... target footpring ...growth limit

I am using React Native to develop an app. I get an error when trying to upload a video more than 20 sec. The code works fine for small videos. const response = await fetch(videoPicker) const blob = await response.blob() const path =…
1
vote
3 answers

Images put to storage are saved as 'octet-stream' rather than image/jpeg (firebase and ReactNative)

I am using the camera(react-native-image-Picker) to take a pick and save it to storage. Here is how I am doing it. const saveImage = async () => { const id = firebase.firestore().collection('food').doc().id const storageRef =…
1
vote
0 answers

How can i set number of maxFile in react-native-image-crop-picker in Android in React Native?

I want to select only 5 image ,when gallary will open.but it is giving me chance to select all gallary images...in Android (React Native) const openGalary = () => { ImagePicker.openPicker({ mediaType:'photo', width: 300, height: 400, multiple:…
1
vote
0 answers

I am facing below reacr-native app crash issues

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference at com.imagepicker.utils.MediaUtils.readExifInterface(MediaUtils.java:267) at…
1
vote
0 answers

Image displayed as white in react native

I am using react-native-image-crop-picker to upload images from my device to the backend server. I am able to upload and save images to the server successfully. But If I sign out from my application and sign in back, the image filed is showing as…