Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49230

Error while Decoding QR Code from Gallery in IONIC

$
0
0

@IonicDeveloper02 wrote:

I need to decode QR image from gallery in ionic. I am using the following code to get the image from gallery and decode it,

gallery() { 

    let options = {
        destinationType: this.camera.DestinationType.FILE_URI,
        sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
      };


      this.camera.getPicture(options).then((imageData) => {

        this.base64String = imageData;
        this.decodeImg((response) => {
          console.log("response:", response);
          if (response && response != "error in decoding QR Code" && response != "error decoding QR Code") {
            console.log(“Decoded Data ”, response);
          }
          else {
             console.log(“Error”);
          }
        });

      }, (err) => {
        console.log(“Error”, err);
      });
} 

    decodeImg(callback) {
    this.decodeImageFromBase64( this.base64String, (decodedInformation) => {
    console.log("Final Output  ", decodedInformation); 
    callback(decodedInformation);
  });

}


    decodeImageFromBase64(data, callback) {
    try {
      // set callback
      qrcode.callback = callback;
      // Start decoding
      qrcode.decode(data);

      } catch (error) {
      console.log("error  ", error); 
    }
    }

The problem is, some QR getting decoded properly and for some QR i am receiving “error in decoding QR Code”. But the same QR working fine in online decoder. Kindly let me know, the solution why some QR not decoding properly.

Kindly let me know what is the alternate way to decode QR image from gallery in ionic?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49230

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>