npm

mrz-scan

1.2.0 • Public • Published

mrz-scanner

Server side mrz scanner.

Using mrz-detection written for NodeJS by Daniel Kostro and Michaël Zasso.

Based on mrz-scanner

Refactored by ProjectINT because original package was to big for lambda function

Install

yarn add mrz-scan
      OR
npm i mrz-scan

Get formatted response

// @flow
const mrzScanner = require('mrz-scan');

type Result = ?{ // undefined if errored
  number: string,
  validDate: string,
  birthDate: string,
  name: string,
  surname: string,
};

// Pass [Buffer](https://nodejs.org/api/buffer.html) to mrzScanner
const result: Result = await mrzScanner(Buffer);

Or you can get all fields with original === true option

// @flow
const mrzScanner = require('mrz-scan');

type Fields = {
  documentCode: string,
  issuingState: string,
  lastName: string,
  firstName: string,
  documentNumber: string,
  documentNumberCheckDigit: string,
  nationality: string,
  birthDate: string,
  birthDateCheckDigit: string,
  sex: string,
  expirationDate: string,
  expirationDateCheckDigit: string,
  personalNumber: string,
  personalNumberCheckDigit: string,
  compositeCheckDigit: string,
}

type FullResult = ?{ // undefined if errored
  format: string, // TD1, TD2, TD3
  details: Array<{
    label: string,
    field: $Values<Fields>,
    value: string,
    valid: boolean,
    ranges: Array<[number, number]>,
    line: number,
    start: number,
    end: number,
  }>,
  fields: Fields,
  valid: boolean,
}

const fullResult: FullResult = const result = await mrzScanner(Buffer, { original: true });

Supported image formats

Supported image formats The following formats can be loaded by image-js:

  • PNG (8 or 16 bits, color or greyscale, with or without alpha)
  • JPEG
  • TIFF (8 or 16 bits, greyscale)

Package Sidebar

Install

npm i mrz-scan

Weekly Downloads

291

Version

1.2.0

License

AGPL-3.0-or-later

Unpacked Size

9.72 MB

Total Files

183

Last publish

Collaborators

  • projectint