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
2
votes
0 answers

How to close/cancel camera roll/image gallery using react-native-image-crop-picker

I'm implementing react-native-image-crop-picker in my app and I'm able to open it and pick images but I don't see a way to cancel out of it or close it -- see below: Once the camera roll/image gallery opened, I want to give the user a way to cancel…
Sam
  • 26,817
  • 58
  • 206
  • 383
2
votes
0 answers

java.lang.RuntimeException com.imagepicker.ImagePickerModule.onActivityResult

My app crashes while using react-native-image-picker library in my android app. I am using react-native-image-picker library to select image from the gallery and capture a photo from the camera. I am not able to find any solution regarding this…
Shivam
  • 2,147
  • 1
  • 11
  • 28
2
votes
1 answer

image quality not reducing after selecting image from react-native-image-picker

I am using react-native-image-picker to select images from gallery, but react-native-image-picker not reducing image quality after selecting an image. Both original and compressed images size are the same. How to reduce image quality by using…
Shivam
  • 2,147
  • 1
  • 11
  • 28
2
votes
1 answer

How to convert image URI to Byte[](Byte array) in React Native

I need to upload image to server. The server require image in byte array. I'm using react-native-image-picker to select image from device. It returns URI(image path), which I need to convert to byte Array. Is there any way to image path to byte…
2
votes
5 answers

react-native-image-picker response.uri is undefined

In my react-native app, I using react-native-image-picker to pick image from camera or gallery. But the resource.uri returned in undefined in both launchCamera and launchImageLibrary. What am I doing wrong? Here is my github repo of a basic build of…
user2243481
  • 551
  • 5
  • 8
2
votes
2 answers

How to await for the react native Image Picker callback function response?

I want to make a function that uploads a photo picked from the react-native-image-picker to firestore, and then returns the value of the URL of the uploaded image. The photo uploads succesfully and I can print in console the download URL, the…
2
votes
0 answers

expo-image-picker: app shows all photos even if I choose the "selected photos" permission - iOS 14.0+ only

I am using the expo-image-picker for photo management. When I choose the "selected photos" permission and open the photo library, photo library shows all photos regardless it's permission status(selected photos). This is happening in iOS14.0+…
heltdev
  • 943
  • 1
  • 8
  • 19
2
votes
0 answers

Not able to get Metadata using react-native-media-meta library for ios

I want to get media file (video/audio) file metadata to get file duration for that I'm using "react-native-media-meta" library and it is working perfectly on Android. But on iOS, it is not working. Kindly help. ImagePicker.showImagePicker( {…
2
votes
1 answer

React-native-image-picker add mask layout to camera

I'm making an app, that implements taking photos or uploading them from gallery. I would like to find out, if it is and how it is possible to add a mask layout for camera view. The result i would like to get is : Is it possible to achieve this with…
2
votes
3 answers

How to give option to select image only from gallery in react-native-image-picker?

The below code give popup showing camera or choose from gallery. I do not want camera option in this. I want to launch gallery when this function is called. Is there any way to do that? import ImagePicker from 'react-native-image-picker'; function…
Developer
  • 123
  • 1
  • 3
  • 14
2
votes
1 answer

React Native Image Upload File Extension Error

I am trying to upload an image to Django backend server with React Native. const addPostHandle = () => { const formData = new FormData() formData.append("image", { name: "img", type: image.mime, size: image.size, …
altF4
  • 269
  • 4
  • 19
2
votes
0 answers

react-native-image-picker upload image fetch network error

I use react-native-image-picker to upload image to a server. I use the following code: sendPhoto = async () =>{ const fileToUpload = { type:'image/jpg', uri: 'file://'+this.state.photo.path, name:'uploadimage.jpg' } …
2
votes
2 answers

React-native-image-picker image fileName is null

developers, I am using react-native-image-picker to upload images to the Nodejs server and MongoDB, when I select an image on react native app it is showing image fileName="null" on the console log. I am struggling for 3 weeks and couldn't find any…
Bipul Prasai
  • 21
  • 1
  • 3
2
votes
1 answer

React Native image picker image upload not working on iOS

I am having trouble in uploading an image via fetch and react-native-image-picker to Multer and Express backend. Below is my React Native code: try { const data = new FormData(); data.append('image', { name: photo.fileName, type:…
HexaCrop
  • 3,863
  • 2
  • 23
  • 50
2
votes
1 answer

How to delete react-native-image-crop-picker image from /storage/emulated/0/Pictures

When the image is captured it saves two images, one original and the other compressed and gives the path of compressed image in image.path. How can I disable saving of any image in gallery, I just need the base64 to work…