Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const path = require('path');
const Image = require('image-js').Image;
const { getMrz, readMrz } = require('../..');
it(
'test the extraction of MRZ characters on an identity card',
async () => {
const img = await Image.load(path.join(__dirname, 'fixtures/id1.jpg'));
let mrzImage = getMrz(img);
// mrzImage.save('./test.jpg');
let { mrz } = await readMrz(mrzImage);
expect(mrz).toMatchSnapshot();
},
15000
);
it(
'use strict';
const fs = require('fs');
const IJS = require('image-js').Image;
const parse = require('mrz').parse;
const tableify = require('tableify');
const { join } = require('path');
const runMRZ = require('../src/runMRZ');
const loadFontFingerprint = require('../src/util/loadFontData');
const symbols = require('../src/util/symbolClasses').MRZ; // SYMBOLS MRZ NUMBERS
const codes = {
PREPROCESS_ERROR: {
code: 0,
save: 'preprocess'
},
CORRECT: {
code: 1,
save: 'correct'
'use strict';
const path = require('path');
const fs = require('fs-extra');
const IJS = require('image-js').Image;
const extensions = ['.png', '.jpeg', '.jpg'];
async function writeImages(images) {
if (!Array.isArray(images)) {
images = [images];
}
// eslint-disable-next-line no-await-in-loop
for (let entry of images) {
const { image, filePath, ...metadata } = entry;
if (!image || !filePath) {
throw new Error('image and filePath props are mandatory');
}
const baseDir = path.resolve(path.dirname(filePath));
await fs.mkdirp(baseDir);
'use strict';
const fs = require('fs');
const { join } = require('path');
const IJS = require('image-js').Image;
const tableify = require('tableify');
const { loadAllFontData, runFontAnalysis } = require('ocr-tools');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
var {
codes,
fingerprintOptions,
roiOptions,
getFunctions
} = require('./MRZDetection');
// options
const maskOptions = {
invert: true,
algorithm: 'isodata'
'use strict';
const { join, resolve, extname, parse: parsePath } = require('path');
const { getLinesFromImage } = require('ocr-tools');
const fs = require('fs-extra');
const minimist = require('minimist');
const IJS = require('image-js').Image;
const { writeImages } = require('../src/util/readWrite');
const roiOptions = require('../src/roiOptions');
const argv = minimist(process.argv.slice(2));
exec().catch(console.error);
async function exec() {
let outDir;
const expected = await getExpected();
if (!argv.outDir) {
throw new Error('you must specify an output director with --outDir');
} else {
outDir = resolve(argv.outDir);
'use strict';
const { join, resolve, extname, parse: parsePath } = require('path');
const fs = require('fs-extra');
const minimist = require('minimist');
const IJS = require('image-js').Image;
const { parse } = require('mrz');
const { readMrz } = require('..');
const argv = minimist(process.argv.slice(2));
exec().catch(console.error);
const stats = {
total: 0,
valid: 0,
couldParse: 0
};
async function exec() {
const expected = await getExpected();
'use strict';
const IJS = require('image-js').Image;
const fs = require('fs');
const tableify = require('tableify');
const tanimoto = require('ml-distance').similarity.tanimoto;
const rootDir = '..';
const readPath = `${rootDir}/data/id/`;
const saveMask = `${rootDir}/mask/`;
const saveMRZ = `${rootDir}/mrz/`;
const saveHTMLFile = 'passport.html';
const roiOptions = {
minSurface: 200,
positive: true,
negative: false,
minRatio: 0.5,
maxRatio: 2.0
const extracted = async (image: Image) => {
const data = await ImageJS.Image.load(image.data);
return tensorflow.tidy(() => {
return tensorflow.browser
.fromPixels(imageToSquare(data.getCanvas(), 224))
.toFloat()
.sub(tensorflow.scalar(127.5))
.div(tensorflow.scalar(127.5))
.reshape([1, 224, 224, 3]);
});
};