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
0
votes
1 answer

Expo image picker cannot show image on web that uploaded from Mobile due to different url in React Native

I uploaded image from web account, this image showing on mobile as well but when I uploaded image from mobile it cannot display on web or any other mobile Because in database web image uri is readable but mobile image uri not readable My Image…
0
votes
2 answers

react-native-image-picker getting reverse height and width

I am using react-native-image-picker library to capture image code as follow: launchImageLibrary({ includeExtra: false, mediaType: "photo", selectionLimit: 0, quality: 1, maxWidth: 1000, maxHeight: 1500 }, (res)=>{ …
Khurshid Ansari
  • 4,638
  • 2
  • 33
  • 52
0
votes
1 answer

how can i convert image uri to base64?

I am using react-native-image-picker along with react-native-photo-editor .. photo editor returns uri of the edited image while my api supports base64, is there a way I can convert the edited image uri to base64 encoding ? this is my code…
0
votes
2 answers

How to upload image with react native?

I upload image with react js like this : const onSubmit = (e) => { console.log(e.img); form.append("file", e.img.originFileObj); Axios.post("url", form, { headers: { Authorization: `bearer…
0
votes
0 answers

imagePicker caused app restart in android

i am working on a project i need to use the camera i generate react native version 66.1 and i installed the latest version of react-native-image-piker 4.1.2 no permission needed and this is the simple code try { launchCamera({quality: 1},…
DiveDive
  • 88
  • 5
0
votes
1 answer

Is it a good practice saving multiple images in redux store?

I have a form in react native which allows uploading multiple pictures, but actual uploading is only done after clicking "Submit" button, which in this case I am saving the selected images to the state via redux and it would live in the state until…
zyneragetro
  • 139
  • 1
  • 2
  • 13
0
votes
1 answer

React Native: Uncaught Error undefined is not an object (evaluating '_reactNativeImagePicker.default.showImagePicker')

I have followed this tutorial to create an image upload app using Firebase and got to the very end and when I build the app using npx react-native run-ios I get this error: Uncaught Error undefined is not an object…
0
votes
2 answers

upload images to laravel server from react native

How should I upload my pictures to laravel server using fetch method in react native? I am using react-native-image-picker in my react native project and follow that package https://aboutreact.com/example-of-image-picker-in-react-native/ and my…
0
votes
1 answer

Make one function wait for another...Async/ Await

When I pick an image using react-native-image-picker everything works as expected. I then pass the response to a function to upload the image to firebase storage. On my device, this seems to work, but then I get the following error: Possible…
0
votes
1 answer

Upload Video URI from React-Native Picker to AWS S3 Server

I am trying to upload a video from my IOS device library to S3 using axios and a pre-signed url. I've determined the axios/s3 part is working great, but the issue is coming from the uri I receive from 'react-native-image-picker'. When I record a…
0
votes
1 answer

How can i automatically crop an image just taken with react-native-camera

I have a feature that captures a bank card, how can I crop the image of the card inside the camera mask. I use react-native-camera to take pictures and use BarcodeMask to create masks.Here is the code:
0
votes
1 answer

React native how to upload multiple images to server (backend)

for single Image upload working but multiple images upload not working const data = new FormData(); //sending data to backend in the form of array data.append("media_files", [{ uri: item.uri, …
0
votes
1 answer

Where is image data in React?

Im using the following function to upload an image to our application: const result = await ImagePicker.launchCameraAsync({ allowsEditing:true, }); This returns the following object: Object { "cancelled": false, …
0
votes
1 answer

React-Native-Image-Picker: How do I restrict user to upload video more than given length?

Can I do something to restrict a user to upload a video of duration more than 300 seconds? Either the bigger videos should be trimmed to 300s or the videos more than 300s should be disabled. I use durationLimit prop which is not working for android.…
0
votes
1 answer

Converting image (iOS) URI from react-native-image-picker to path using rn-fetch-blob

I'm using react-native-image-picker to pick the images. After picking image, I want to upload these image to server using fetch, there I need an absolute file path. So, for converting URI to path I'm using rn-fetch-blob, but it is throwing errors as…
Harsha
  • 760
  • 1
  • 7
  • 21