remobile / react-native-qrcode-local-image

A local qrcode image parse for react-native
MIT License
55 stars 72 forks source link

I can't recognise QR on some images on ios #12

Open ivan133 opened 5 years ago

ivan133 commented 5 years ago

I'm using your package to recognise qr from image. But mostly it returns error "Feature size is zero!" Althoght the image is pretty good quality. Also it works perfectly on android with the same image.

I'm using react-native-image-picker to get image. But looks like it return full size images.

  _selectImage = () => {
    const options = {
      storageOptions: {
        skipBackup: true,
        path: 'images'
      }
    };

    ImagePicker.launchImageLibrary(options, (response) => {
      if (response.didCancel) {
        // console.log('User cancelled image picker');
      } else {
        this.setState({
          imagePath: response.uri,
          imageRotation: response.originalRotation || 0
        });
        console.log('response', response)
        QRCodeReader.decode(Platform.OS === 'ios' ? response.uri.replace('file://', '') : response.path || response.uri, (error, result)=>{
          console.log('error', error);
          console.log('result', result);
          if (error){
            if (error.message === 'Feature size is zero!'){
              Alert.alert(I18n.t('generic.error'), I18n.t('qr_content.qr_code_not_found'));

            } else {
              Alert.alert(I18n.t('generic.error'), I18n.t('qr_content.qr_code_not_found' + ' ' + error.message));
            }
          } else {
            if (result){
              Alert.alert('result', result);
            } else {
              Alert.alert(I18n.t('generic.error'), I18n.t('qr_content.cant_decode_kf_qr'));
            }
          }
        });
      }
    });
  };
ivan133 commented 5 years ago

The QR on the image is rotated to 45 deg but it should not be a problem, right?