Closed filirnd closed 4 years ago
Hi, I have a problem with decode this image that contains qr code
My code is the follow and i can decode the image with online zxing web app.
func qrDecoder(localQrPath string) (*gozxing.Result,error) { // open and decode image file file, err := os.Open(localQrPath) if err != nil { return nil,err } img, _, err := image.Decode(file) if err != nil { return nil,err } src := gozxing.NewLuminanceSourceFromImage(img) // prepare BinaryBitmap bmp, err := gozxing.NewBinaryBitmap(gozxing.NewGlobalHistgramBinarizer(src)) if err != nil { return nil,err } // decode image hints := map[gozxing.DecodeHintType]interface{}{ //gozxing.EncodeHintType_ERROR_CORRECTION: decoder.ErrorCorrectionLevel_L, gozxing.DecodeHintType_TRY_HARDER: true, gozxing.DecodeHintType_POSSIBLE_FORMATS: []gozxing.BarcodeFormat{ gozxing.BarcodeFormat_QR_CODE }, } qrReader := qrcode.NewQRCodeReader() return qrReader.Decode(bmp, hints) }
It return "image: unknown format" error.
I've found the mistake. Need to import this _ "image/jpeg"
_ "image/jpeg"
Hi, I have a problem with decode this image that contains qr code
My code is the follow and i can decode the image with online zxing web app.
It return "image: unknown format" error.