Scanner for static images, typically provided via an HTML input element.

Remarks

Make sure that the input image is sharp, and that the code to be scanned is in focus. Some images might not scan using ImageScanner, but can be scanned using camera-based scanning (BarcodeReader, PopupScanner). This is due to more frames being available for decoding, increasing the chances of getting a good quality sample.

Example

HTML:

<input id="image-input" type="file" accept="image/*" />

JavaScript:

const imageInput = document.getElementById('image-input');
imageInput.onchange = async () => {
const detections = await ImageScanner.scan(image.files[0], {
engine: { symbologies: ['qr'] }
});
}

Methods

Methods

  • Decode a barcode in a static image.

    Parameters

    • image: ImageSource

      The image source, can be a HTMLImageElement, ImageData, ImageBitmap, File, Blob or a data URL.

    • cfg: ImageConfiguration

      The engine configuration to use for barcode detection.

    Returns Promise<CodeDetection[]>

    Remarks

    By default, a single barcode is detected. In a future release, an option to detect multiple barcodes will be added.