How to use react-native-image-picker - 10 common examples

To help you get started, we’ve selected a few react-native-image-picker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github transloadit / uppy / examples / react-native / App.js View on Github external
// Permissions.askAsync(Permissions.CAMERA_ROLL).then((isAllowed) => {
    //   if (!isAllowed) return

    //   ImagePicker.launchImageLibraryAsync({
    //     mediaTypes: 'All'
    //   })
    //     .then((result) => {
    //       console.log(result)
    //       if (!result.cancelled) {
    //         this.setState({ file: result })
    //         this.addFile(result)
    //       }
    //     })
    // })

    ImagePicker.showImagePicker({}, (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 };
github BrightID / BrightID / old-rn / src / components / SignUp.js View on Github external
getAvatarPhoto = () => {
		// see https://github.com/react-community/react-native-image-picker
		// for full documentation on the Image Picker api

		const options = {
			title: "Select Avatar",
			customButtons: [{ name: "fb", title: "Choose Photo from Facebook" }],
			storageOptions: {
				skipBackup: true,
				path: "images"
			}
		};

		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 {
				let source = { uri: response.uri };

				// You can also display the image using data:
				// let source = { uri: 'data:image/jpeg;base64,' + response.data };

				this.setState({
					avatarSource: source
github easemob / webim-react-native / App / Containers / MessageScreen.js View on Github external
handleImagePicker() {
    this.setState({
      isEmoji: false
    })
    ImagePicker.launchImageLibrary(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 {
          // You can display the image using either data...
          //const source = {uri: 'data:image/jpeg;base64,' + response.data, isStatic: true};

          // or a reference to the platform specific asset location
github jessieeeee / SimpleOne / js / remark / ChangeImg.js View on Github external
openLibrary() {
        // Open Image Library:
        ImagePicker.launchImageLibrary(options, (response) => {
            // Same code as in above section!
            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 {
                // let source = { uri: 'data:image/jpeg;base64,' + response.data };
                // console.log('source = ', source);
                this.props.route.params.response(response)
github 15826954460 / BXStage / app / pages / my / accountInfo / index.js View on Github external
Permissions.request('camera').then(res => {
        switch (res) {
          case "authorized":
            /** 调用系统拍照功能 */
            ImagePicker.launchCamera({}, response => {
              if (response.didCancel) {
                // window.console.log('User cancelled image picker');
              }
              else if (response.error) {
                // window.console.log('ImagePicker Error: ', res.error);
              }
              else if (response.customButton) {
                // window.console.log('User tapped custom button: ', response.customButton);
              }
              else {
                this.setState({
                  headPicture: response.uri
                })
              }
            })
            break;
github jessieeeee / SimpleOne / js / remark / ChangeImg.js View on Github external
openCamera() {
        // Launch Camera:
        ImagePicker.launchCamera(options, (response) => {
            // Same code as in above section!
            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 {
                // let source = { uri: 'data:image/jpeg;base64,' + response.data }
                // console.log('source = ', source)
                this.props.route.params.response(response)
github 15826954460 / BXStage / app / pages / my / userFeedback / noFeedBack.js View on Github external
Permissions.request('camera').then(res => {
        switch (res) {
          case "authorized":
            /** 调用系统拍照功能 */
            ImagePicker.launchCamera({}, response => {
              if (response.didCancel) {
                // window.console.log('User cancelled image picker');
              }
              else if (response.error) {
                // window.console.log('ImagePicker Error: ', res.error);
              }
              else if (response.customButton) {
                // window.console.log('User tapped custom button: ', response.customButton);
              }
              else {
                if (ImageData.selectImgList.length < 4) {
                  ImageData.selectImgList.push({
                    uri: response.uri,
                    isSelect: true,
                    filename: response.uri.slice(response.uri.lastIndexOf('/') + 1)
                  })
github easemob / webim-react-native / App / Containers / MessageScreen.js View on Github external
handleCameraPicker() {
    this.setState({
      isEmoji: false
    })
    // Launch Camera:
    ImagePicker.launchCamera(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 {
        // You can display the image using either data...
        //const source = {uri: 'data:image/jpeg;base64,' + response.data, isStatic: true};

        // or a reference to the platform specific asset location
github mtford90 / react-native-watch-connectivity / example / app / images.js View on Github external
cancelButtonTitle: 'Cancel',
      takePhotoButtonTitle: 'Take Photo...',
      chooseFromLibraryButtonTitle: 'Choose from Library...',
      cameraType: 'front',
      mediaType: 'photo',
      quality: 0.5,
      allowsEditing: true,
      noData: !data,
      storageOptions: {
        skipBackup: true,
        path: 'images',
      },
      ...xtra,
    };

    ImagePicker.showImagePicker(options, response => {
      const { error } = response;
      if (response.didCancel) {
        // Do nothing
      } else if (error) {
        reject(error);
      } else {
        if (data && response.data) {
          let dataUri = 'data:image/jpeg;base64,' + response.data;
          response.dataUri = dataUri;
        }
        resolve(response);
      }
    });
  });
}
github buildreactnative / assemblies / application / components / accounts / RegisterConfirmation.js View on Github external
showImagePicker(){ /* select image from camera roll for avatar */
    ImagePicker.showImagePicker(ImageOptions, (response) => {
      if (response.didCancel || response.error) { return; }
      const avatar = 'data:image/png;base64,' + response.data;
      this.setState({ avatar });
    });
  }
  selectTechnology(technology){

react-native-image-picker

A React Native module that allows you to use native UI to select media from the device library or directly from the camera

MIT
Latest version published 3 months ago

Package Health Score

87 / 100
Full package analysis