How to use the react-native-image-picker.launchImageLibrary function in react-native-image-picker

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 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 strivert / react-native-real-property-reports / src / screens / Setup.js View on Github external
onFromPickerImage={()=>{
            var options = {
              title: 'Select Avatar',
              storageOptions: {
                skipBackup: true,
                path: 'images'
              }
            };
            ImagePicker.launchImageLibrary(options, (response)  => {
              // Same code as in above section!
              let source = { uri: response.data };

              if (response.data) {
                if (clickedPage =='report') {
                  this.props.addressActions.addImage({res: response.data});
                } else {
                  this.props.accountActions.addImage({res: response.data});
                }
              }

            });
          }}
        />
github atulmy / fullstack-javascript-architecture / frontend / app / mobile / src / modules / user / Profile / MyInfo / index.js View on Github external
const onSelectImage = () => {
    isUploadingToggle(true)

    ImagePicker.launchImageLibrary({
      title: translate.t('user.avatar'),
      noData: true,
      allowsEditing: true,
      mediaType: 'photo'
    }, async response => {
      if (response.didCancel) {
        isUploadingToggle(false)

      } else if (response.error) {
        isUploadingToggle(false)

        // Error selecting image
        dispatch(messageShow({ success: false, message: translate.t('common.error.default') }))
      } else {
        // Image selection successful
        await uploadImage(response)
github strivert / react-native-real-property-reports / src / components / Molecule / CameraPic.js View on Github external
fromPicker() {
    var options = {
      title: 'Select Avatar',
      storageOptions: {
        skipBackup: true,
        path: 'images'
      }
    };
    ImagePicker.launchImageLibrary(options, (response)  => {
      // Same code as in above section!
      let source = { uri: response.data };

      if (response.data) {
        this.setState(
          update(this.state, {
            images: { 
              $push: [{
                'backImage': response.data,
                'drawImage': ''
              }]
            },
            isCamera: {$set: false},
            selectedIndex: {$set: 0},
            isDraw: {$set: false}
          })
github shifeng1993 / react-native-qr-scanner / example / src / Reader.js View on Github external
openPhoto(){
    console.log('ImagePicker');
    ImagePicker.launchImageLibrary({}, (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 {
        if(response.uri){
          var path = response.path;
          if(!path){
              path = response.uri;
github RN-ONE / RNFrameWorkNew / app / overlay / ImagePickerOverlay.js View on Github external
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE], () => {
                                                //打开系统相册
                                                ImagePicker.launchImageLibrary(AppConfig.IMAGE_PICKER_OPTIONS, (response) => {
                                                    this.dismissOverlay();
                                                    //响应结果处理参考上面样例
                                                    console.log(response);
                                                    if (!response.error && response.uri && this.props.callback) {
                                                        this.props.callback({
                                                            uri: response.uri,
                                                            path: response.path,
                                                            fileSize: response.fileSize,
                                                            fileName: response.fileName,
                                                            width: response.width,
                                                            height: response.height,
                                                        });
                                                    } else {
                                                        ToastAI.showShortBottom("打开图库失败");
                                                    }
                                                });
github BlueWallet / BlueWallet / screen / send / scanQrAddress.js View on Github external
onPress={() => {
            if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.pausePreview();
            ImagePicker.launchImageLibrary(
              {
                title: null,
                mediaType: 'photo',
                takePhotoButtonTitle: null,
              },
              response => {
                if (response.uri) {
                  const uri = Platform.OS === 'ios' ? response.uri.toString().replace('file://', '') : response.path.toString();
                  LocalQRCode.decode(uri, (error, result) => {
                    if (!error) {
                      this.onBarCodeRead({ data: result });
                    } else {
                      if (RNCamera.Constants.CameraStatus === RNCamera.Constants.CameraStatus.READY) this.cameraRef.resumePreview();
                      alert('The selected image does not contain a QR Code.');
                    }
                  });
github N3TC4T / Nearby-Live / src / containers / main / home / conversations / conversation / Render / Actions.js View on Github external
showMediaPicker = (type) => {
        this.setState({
            assetType: type,
            asset: null,
            loading: true
        });

        ImagePicker.launchImageLibrary(mediaOptions[type], (response) => {
            if (!response.didCancel && !response.error) {
                let source = {uri: `data:image/jpeg;base64,${response.data}`, isStatic: true};
                if (Platform.OS === 'ios') {
                    source = {
                        ...source,
                        path: response.uri.replace('file://', ''),
                        assetURL: response.origURL,
                        width: response.width,
                        height: response.height
                    };
                } else {
                    source = {
                        ...source,
                        path: response.path,
                        width: response.width,
                        height: response.height
github keybase / client / shared / chat / conversation / input-area / normal / platform-input.native.js View on Github external
if (response.error) {
        this.props.onFilePickerError(new Error(response.error))
        return
      }
      const filename = isIOS ? response.uri.replace('file://', '') : response.path
      if (filename) {
        this.props.onAttach([filename])
      }
    }

    switch (location) {
      case 'camera':
        launchCamera({mediaType, permissionDenied, takePhotoButtonTitle, title}, handleSelection)
        break
      case 'library':
        launchImageLibrary({mediaType, permissionDenied, takePhotoButtonTitle, title}, handleSelection)
        break
    }
  }

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 13 days ago

Package Health Score

95 / 100
Full package analysis