quaggaJS icon indicating copy to clipboard operation
quaggaJS copied to clipboard

Quagga unable to read code generated from pdf to image

Open redochka opened this issue 1 year ago • 2 comments

I am extracting a barcode from a pdf using FPDF than converting it to an image using pdf.js

The barcode is readable by other bar code scanner tools. however quaggajs is not able to detect it.

I am using the basic nodejs example which works with other barcodes.

What could be wrong with a barcode found in a pdf and converted to an image? output0 output_page-0001

redochka avatar Jul 30 '24 12:07 redochka

Hi there! Usually, the problem that I see is that there's zero whitespace around the image, which causes it to not understand where the barcode is. That doesn't appear to be the case here, but it is quite a large barcode, so I'm guessing resolutions may not be configured to handle this.

Can you provide your quagga configuration block? Also, which of these two images are we talking about? both?

ericblade avatar Aug 10 '24 06:08 ericblade

Hey, yes problem happening with both images. The large image with lot of blank is just an experiment to see if it would help. My quagga config is basic:

Quagga.decodeSingle({
  // src         : "pwlo858qvoc2cgy6aqijt9ctmiszwqreypqlw7xu_page-0001.jpg",
  src         : "output0.png",
  numOfWorkers: 0,  // Needs to be 0 when used within node
  // inputStream : {
  //   size: 2000  // restrict input-size to be 800px in width (long-side)
  // },
  decoder     : {
    readers: [
      "code_128_reader",
      "ean_reader",
      "ean_8_reader",
      "code_39_reader",
      "code_39_vin_reader",
      "codabar_reader",
      "upc_reader",
      "upc_e_reader",
      "i2of5_reader",
      "2of5_reader",
      "code_93_reader",
    ], // List of active readers
    locate: true,
    debug: {
      drawBoundingBox: false,
      showFrequency: false,
      drawScanline: false,
      showPattern: false
    }

  },
}, function (result) {
  console.log("result", result);

  if (result && result.codeResult) {
    console.log("result.codeResult", result.codeResult);
    console.log("result", result.codeResult.code);
  } else {
    console.log("not detected");
  }
})

redochka avatar Aug 18 '24 19:08 redochka