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

Cloudinary upload image not working (react native and nodes

I am trying to upload an image from my react native app to the nodejs and to the cloudinary cloud, but its not working for me. Thats my react-native code: const App = () => { const [profileImageSource ,setProfileImageSource] =…
0
votes
0 answers

ReactNative app when compiled for Mac gets error AssetsLibrary is deprecated

I am trying to build and iPad app for mac platform which is built on react-native platform. while compiling the code i am getting error AssetsLibrary is deprecated and is not available when building for Mac Catalyst.Consider migrating to Photos…
Mihir Mehta
  • 13,743
  • 3
  • 64
  • 88
0
votes
0 answers

How to decompress the image in react native

I want to compress the image before saving it in database add decompress the image before displaying. I compress the image using 'react-native-image-resizer' and i got base64. How can i decompress the image to get the original quality image?
0
votes
1 answer

Images and Videos are not uploading to server using axios while in debugging mode

I'm using react-native-image-crop-picker to get image from gallery and trying to upload it on the server using Axios.But its not uploading to the server and when I hit the api to upload it starts sending and never-ending and no response getting from…
0
votes
1 answer

Image upload with react native axios

I am trying to upload image via axios to an API but I have issues the server sends no response at all no error this is the code image picker const showImage = () => { ImagePicker.showImagePicker(options, (response) => { if (response.didCancel) { …
0
votes
3 answers

Image is not shown after it is selected from react-native-image-picker

I am developing an app in which i need to upload an image from my phone, once i click upload gallery is shown and i am able to select the image but once the image is selected the image is not shown in image container i have used. my code This is…
0
votes
1 answer

Firebase Cloud Storage Error Loading Preview Uploaded Image

I uploaded an image using react-native-image-picker's base64 generated data. It shows up on Firebase console fine, but when I try to look at it on my browser, it says "Error Loading Preview" and when I click on it, it is just a black box. See…
0
votes
0 answers

Upload image to server with react-native-image-picker got error

Today I try to upload an image from my phone to server using react-native-image-picker but I got problem with it. Here my code: ImagePicker.showImagePicker(options, (response) => { if (response.didCancel) { …
0
votes
0 answers

JS async return not accessible outside of local scope

I appreciate any assistance that the community can offer! I have a React-native class component with the getPathForFirebaseStorage method that is called by a different method. However whenever the below method is called it returns : {"_U": 0, "_V":…
0
votes
1 answer

Why does not permitted in android ? using react-native-image-picker

i have a problem. i had added codes for permitting about 'image' but, i had a console.log like…
devsner
  • 379
  • 3
  • 4
  • 11
0
votes
2 answers

How to get the full size photo from gallery using expo image picker

I'm using image picker expo to access my gallery or photos. I want to get the full photo not cropped to be displayed on image here is my code: const image = await ImagePicker.launchImageLibraryAsync({ mediaTypes:…
nani10
  • 301
  • 4
  • 9
0
votes
1 answer

React Native:How to dynamically arrange local images in display when picked from local gallery?

In my RN 0.62.2 app, a function is used to display local images picked from gallery: const displayImg = (img_source, width, ht, local=false) => { if (local) { return (
user938363
  • 9,990
  • 38
  • 137
  • 303
0
votes
3 answers

Image upload issue with react-native and PHP(CodeIgniter) as backend

I have an app scenario with react native and CodeIgniter as backend. I have a code snippet to upload image as picked by react-native-image-picker as below: let formData = new FormData(); let imageBody = { uri: newImage, …
0
votes
2 answers

how to select multiple images using react-native-image-crop-picker in react-native

android not support selecting multiple images using react-native-image-crop-picker , how to fixed it ? enter code here ` handlePickImage = async () => { try { console.log('hit') const images = await…
0
votes
1 answer

Pick images in react native and upload it

I want to upload an array of images using react-native-image-crop-picker but I can't fix it. What I've tried: Fetch (javascript) and also RN-fetch-blob but no luck At first the catch error was network error and now the problem is that I'm sending…