How to use the image-js.Image function in image-js

To help you get started, we’ve selected a few image-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github image-js / mrz-detection / src / __tests__ / readMrz.js View on Github external
'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(
github image-js / mrz-detection / run / getStatistics_old.js View on Github external
'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'
github image-js / mrz-detection / src / util / readWrite.js View on Github external
'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);
github image-js / mrz-detection / run / fullMRZDetection.js View on Github external
'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'
github image-js / mrz-detection / run / writeCharacters.js View on Github external
'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);
github image-js / mrz-detection / run / readMrz.js View on Github external
'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();
github image-js / mrz-detection / run / getMRZdata_old.js View on Github external
'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
github piximi / application / src / network.ts View on Github external
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]);
  });
};

image-js

Image processing and manipulation in JavaScript

MIT
Latest version published 4 months ago

Package Health Score

76 / 100
Full package analysis