nbis-wrapper-js 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/src/an2ktool.d.ts +12 -0
- package/dist/src/an2ktool.js +40 -0
- package/dist/src/bozorth3.d.ts +16 -0
- package/dist/src/bozorth3.js +152 -2
- package/dist/src/chkan2k.d.ts +2 -0
- package/dist/src/chkan2k.js +30 -0
- package/dist/src/cjp2k.d.ts +10 -0
- package/dist/src/cjp2k.js +51 -0
- package/dist/src/cjpeg.d.ts +8 -0
- package/dist/src/cjpeg.js +61 -0
- package/dist/src/cjpegb.d.ts +8 -0
- package/dist/src/cjpegb.js +25 -0
- package/dist/src/cjpegl.d.ts +8 -0
- package/dist/src/cjpegl.js +28 -0
- package/dist/src/cwsq.d.ts +8 -0
- package/dist/src/cwsq.js +22 -0
- package/dist/src/datainfo.d.ts +2 -0
- package/dist/src/datainfo.js +12 -0
- package/dist/src/djp2k.d.ts +10 -0
- package/dist/src/djp2k.js +52 -0
- package/dist/src/djpeg.d.ts +8 -0
- package/dist/src/djpeg.js +64 -0
- package/dist/src/djpegb.d.ts +9 -0
- package/dist/src/djpegb.js +26 -0
- package/dist/src/djpegl.d.ts +9 -0
- package/dist/src/djpegl.js +26 -0
- package/dist/src/dwsq.d.ts +9 -0
- package/dist/src/dwsq.js +23 -0
- package/dist/src/image-convert.d.ts +17 -0
- package/dist/src/image-convert.js +118 -0
- package/dist/src/intr2not.d.ts +8 -0
- package/dist/src/intr2not.js +22 -0
- package/dist/src/jpegtran.d.ts +8 -0
- package/dist/src/jpegtran.js +82 -0
- package/dist/src/mindtct.d.ts +18 -0
- package/dist/src/mindtct.js +80 -25
- package/dist/src/nfiq.d.ts +14 -0
- package/dist/src/nfiq.js +71 -21
- package/dist/src/not2intr.d.ts +13 -0
- package/dist/src/not2intr.js +22 -0
- package/dist/src/rdjpgcom.d.ts +3 -0
- package/dist/src/rdjpgcom.js +17 -0
- package/dist/src/rdwsqcom.d.ts +2 -0
- package/dist/src/rdwsqcom.js +12 -0
- package/dist/src/rgb2ycc.d.ts +8 -0
- package/dist/src/rgb2ycc.js +25 -0
- package/dist/src/temp-io.d.ts +15 -0
- package/dist/src/temp-io.js +102 -0
- package/dist/src/wrjpgcom.d.ts +7 -0
- package/dist/src/wrjpgcom.js +26 -0
- package/dist/src/wrwsqcom.d.ts +8 -0
- package/dist/src/wrwsqcom.js +21 -0
- package/dist/src/ycc2rgb.d.ts +13 -0
- package/dist/src/ycc2rgb.js +25 -0
- package/package.json +5 -1
package/dist/src/intr2not.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Intr2not = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
9
|
+
const temp_io_1 = require("./temp-io");
|
|
9
10
|
function buildRawAttr(raw) {
|
|
10
11
|
const attrs = [raw.width, raw.height, raw.depth];
|
|
11
12
|
if (raw.ppi != null) {
|
|
@@ -44,5 +45,26 @@ class Intr2not {
|
|
|
44
45
|
stderr: result.stderr
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
async convertStream(outputExtension, input, options = {}) {
|
|
49
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
50
|
+
const inputPath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
51
|
+
const args = [outputExtension, inputPath];
|
|
52
|
+
if (options.rawIn) {
|
|
53
|
+
args.push('-raw_in', buildRawAttr(options.rawIn));
|
|
54
|
+
}
|
|
55
|
+
if (options.yCbCr) {
|
|
56
|
+
args.push('-YCbCr', buildYCbCr(options.yCbCr));
|
|
57
|
+
}
|
|
58
|
+
const result = (0, nbis_runtime_1.runNbis)('intr2not', args);
|
|
59
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'intr2not');
|
|
60
|
+
const outputPath = replaceExtension(inputPath, outputExtension);
|
|
61
|
+
const outputBuffer = await (0, temp_io_1.deliverTempOutput)(outputPath, options);
|
|
62
|
+
return {
|
|
63
|
+
stdout: result.stdout,
|
|
64
|
+
stderr: result.stderr,
|
|
65
|
+
outputBuffer
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
47
69
|
}
|
|
48
70
|
exports.Intr2not = Intr2not;
|
package/dist/src/jpegtran.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StreamInput, StreamIoOptions } from './temp-io';
|
|
1
2
|
export type JpegtranOptions = {
|
|
2
3
|
optimize?: boolean;
|
|
3
4
|
progressive?: boolean;
|
|
@@ -18,7 +19,14 @@ export type JpegtranResult = {
|
|
|
18
19
|
stderr: string;
|
|
19
20
|
outputPath?: string;
|
|
20
21
|
};
|
|
22
|
+
export type JpegtranStreamOptions = Omit<JpegtranOptions, 'outputPath'> & StreamIoOptions;
|
|
23
|
+
export type JpegtranStreamResult = {
|
|
24
|
+
stdout: string;
|
|
25
|
+
stderr: string;
|
|
26
|
+
outputBuffer?: Buffer;
|
|
27
|
+
};
|
|
21
28
|
export declare class Jpegtran {
|
|
22
29
|
version(): string;
|
|
23
30
|
transform(inputPath: string, options?: JpegtranOptions): JpegtranResult;
|
|
31
|
+
transformStream(input: StreamInput, options?: JpegtranStreamOptions): Promise<JpegtranStreamResult>;
|
|
24
32
|
}
|
package/dist/src/jpegtran.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Jpegtran = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
9
|
+
const temp_io_1 = require("./temp-io");
|
|
5
10
|
class Jpegtran {
|
|
6
11
|
version() {
|
|
7
12
|
const result = (0, nbis_runtime_1.runNbis)('jpegtran', ['-version']);
|
|
@@ -84,5 +89,82 @@ class Jpegtran {
|
|
|
84
89
|
outputPath: options.outputPath
|
|
85
90
|
};
|
|
86
91
|
}
|
|
92
|
+
async transformStream(input, options = {}) {
|
|
93
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
94
|
+
const inputPath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
95
|
+
const outputPath = path_1.default.join(tempDir, 'output.jpg');
|
|
96
|
+
const args = [];
|
|
97
|
+
if (options.optimize) {
|
|
98
|
+
args.push('-optimize');
|
|
99
|
+
}
|
|
100
|
+
if (options.progressive) {
|
|
101
|
+
args.push('-progressive');
|
|
102
|
+
}
|
|
103
|
+
if (options.restart != null) {
|
|
104
|
+
args.push('-restart', String(options.restart));
|
|
105
|
+
}
|
|
106
|
+
if (options.scansFile) {
|
|
107
|
+
args.push('-scans', options.scansFile);
|
|
108
|
+
}
|
|
109
|
+
if (options.transform) {
|
|
110
|
+
switch (options.transform) {
|
|
111
|
+
case 'flip-horizontal':
|
|
112
|
+
args.push('-flip', 'horizontal');
|
|
113
|
+
break;
|
|
114
|
+
case 'flip-vertical':
|
|
115
|
+
args.push('-flip', 'vertical');
|
|
116
|
+
break;
|
|
117
|
+
case 'rotate-90':
|
|
118
|
+
args.push('-rotate', '90');
|
|
119
|
+
break;
|
|
120
|
+
case 'rotate-180':
|
|
121
|
+
args.push('-rotate', '180');
|
|
122
|
+
break;
|
|
123
|
+
case 'rotate-270':
|
|
124
|
+
args.push('-rotate', '270');
|
|
125
|
+
break;
|
|
126
|
+
case 'transpose':
|
|
127
|
+
args.push('-transpose');
|
|
128
|
+
break;
|
|
129
|
+
case 'transverse':
|
|
130
|
+
args.push('-transverse');
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (options.trim) {
|
|
137
|
+
args.push('-trim');
|
|
138
|
+
}
|
|
139
|
+
if (options.grayscale) {
|
|
140
|
+
args.push('-grayscale');
|
|
141
|
+
}
|
|
142
|
+
if (options.copy) {
|
|
143
|
+
args.push('-copy', options.copy);
|
|
144
|
+
}
|
|
145
|
+
if (options.maxMemory) {
|
|
146
|
+
args.push('-maxmemory', options.maxMemory);
|
|
147
|
+
}
|
|
148
|
+
args.push('-outfile', outputPath);
|
|
149
|
+
if (options.verbose) {
|
|
150
|
+
args.push('-verbose');
|
|
151
|
+
}
|
|
152
|
+
if (options.debug) {
|
|
153
|
+
args.push('-debug');
|
|
154
|
+
}
|
|
155
|
+
if (options.extraArgs) {
|
|
156
|
+
args.push(...options.extraArgs);
|
|
157
|
+
}
|
|
158
|
+
args.push(inputPath);
|
|
159
|
+
const result = (0, nbis_runtime_1.runNbis)('jpegtran', args);
|
|
160
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'jpegtran');
|
|
161
|
+
const outputBuffer = await (0, temp_io_1.deliverTempOutput)(outputPath, options);
|
|
162
|
+
return {
|
|
163
|
+
stdout: result.stdout,
|
|
164
|
+
stderr: result.stderr,
|
|
165
|
+
outputBuffer
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
}
|
|
87
169
|
}
|
|
88
170
|
exports.Jpegtran = Jpegtran;
|
package/dist/src/mindtct.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AutoConvertConfig } from './image-convert';
|
|
2
|
+
import type { StreamInput, StreamInputOptions, StreamOutput } from './temp-io';
|
|
1
3
|
export type MindtctDetectOptions = {
|
|
2
4
|
enhanceLowContrast?: boolean;
|
|
3
5
|
useM1?: boolean;
|
|
@@ -18,7 +20,23 @@ export type MindtctDetectResult = {
|
|
|
18
20
|
stdout: string;
|
|
19
21
|
stderr: string;
|
|
20
22
|
};
|
|
23
|
+
export type MindtctConstructorOptions = {
|
|
24
|
+
autoConvert?: boolean | AutoConvertConfig;
|
|
25
|
+
};
|
|
26
|
+
export type MindtctStreamOutputs = Partial<Record<keyof MindtctDetectResult['outputs'], StreamOutput>>;
|
|
27
|
+
export type MindtctStreamOptions = MindtctDetectOptions & StreamInputOptions & {
|
|
28
|
+
outputs?: MindtctStreamOutputs;
|
|
29
|
+
outputToBuffer?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type MindtctStreamResult = {
|
|
32
|
+
outputBuffers?: Partial<Record<keyof MindtctDetectResult['outputs'], Buffer>>;
|
|
33
|
+
stdout: string;
|
|
34
|
+
stderr: string;
|
|
35
|
+
};
|
|
21
36
|
export declare class Mindtct {
|
|
37
|
+
private autoConvert;
|
|
38
|
+
constructor(options?: MindtctConstructorOptions);
|
|
22
39
|
version(): string;
|
|
23
40
|
detect(fingerImagePath: string, outputRoot: string, options?: MindtctDetectOptions): MindtctDetectResult;
|
|
41
|
+
detectStream(input: StreamInput, options?: MindtctStreamOptions): Promise<MindtctStreamResult>;
|
|
24
42
|
}
|
package/dist/src/mindtct.js
CHANGED
|
@@ -6,40 +6,95 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Mindtct = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
9
|
+
const image_convert_1 = require("./image-convert");
|
|
10
|
+
const temp_io_1 = require("./temp-io");
|
|
9
11
|
class Mindtct {
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.autoConvert = (0, image_convert_1.normalizeAutoConvertConfig)(options.autoConvert);
|
|
14
|
+
}
|
|
10
15
|
version() {
|
|
11
16
|
const result = (0, nbis_runtime_1.runNbis)('mindtct', ['-version']);
|
|
12
17
|
(0, nbis_runtime_1.assertSuccess)(result, 'mindtct -version');
|
|
13
18
|
return result.stdout + result.stderr;
|
|
14
19
|
}
|
|
15
20
|
detect(fingerImagePath, outputRoot, options = {}) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
args
|
|
21
|
+
const prepared = (0, image_convert_1.prepareFingerprintImageSync)(fingerImagePath, this.autoConvert);
|
|
22
|
+
try {
|
|
23
|
+
const args = [];
|
|
24
|
+
if (options.enhanceLowContrast) {
|
|
25
|
+
args.push('-b');
|
|
26
|
+
}
|
|
27
|
+
if (options.useM1) {
|
|
28
|
+
args.push('-m1');
|
|
29
|
+
}
|
|
30
|
+
args.push(prepared.path, outputRoot);
|
|
31
|
+
const result = (0, nbis_runtime_1.runNbis)('mindtct', args);
|
|
32
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'mindtct');
|
|
33
|
+
const outputs = {
|
|
34
|
+
mdt: `${outputRoot}.mdt`,
|
|
35
|
+
xyt: `${outputRoot}.xyt`,
|
|
36
|
+
brw: `${outputRoot}.brw`,
|
|
37
|
+
dm: `${outputRoot}.dm`,
|
|
38
|
+
hcm: `${outputRoot}.hcm`,
|
|
39
|
+
lcm: `${outputRoot}.lcm`,
|
|
40
|
+
lfm: `${outputRoot}.lfm`,
|
|
41
|
+
qm: `${outputRoot}.qm`,
|
|
42
|
+
min: `${outputRoot}.min`
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
outputs,
|
|
46
|
+
outputRoot: path_1.default.resolve(outputRoot),
|
|
47
|
+
stdout: result.stdout,
|
|
48
|
+
stderr: result.stderr
|
|
49
|
+
};
|
|
19
50
|
}
|
|
20
|
-
|
|
21
|
-
|
|
51
|
+
finally {
|
|
52
|
+
prepared.cleanup?.();
|
|
22
53
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(0,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
}
|
|
55
|
+
async detectStream(input, options = {}) {
|
|
56
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
57
|
+
const fingerImagePath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
58
|
+
const prepared = (0, image_convert_1.prepareFingerprintImageSync)(fingerImagePath, this.autoConvert, tempDir);
|
|
59
|
+
const outputRoot = path_1.default.join(tempDir, 'output');
|
|
60
|
+
const outputToBuffer = options.outputToBuffer ?? false;
|
|
61
|
+
const args = [];
|
|
62
|
+
if (options.enhanceLowContrast) {
|
|
63
|
+
args.push('-b');
|
|
64
|
+
}
|
|
65
|
+
if (options.useM1) {
|
|
66
|
+
args.push('-m1');
|
|
67
|
+
}
|
|
68
|
+
args.push(prepared.path, outputRoot);
|
|
69
|
+
const result = (0, nbis_runtime_1.runNbis)('mindtct', args);
|
|
70
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'mindtct');
|
|
71
|
+
const outputs = {
|
|
72
|
+
mdt: `${outputRoot}.mdt`,
|
|
73
|
+
xyt: `${outputRoot}.xyt`,
|
|
74
|
+
brw: `${outputRoot}.brw`,
|
|
75
|
+
dm: `${outputRoot}.dm`,
|
|
76
|
+
hcm: `${outputRoot}.hcm`,
|
|
77
|
+
lcm: `${outputRoot}.lcm`,
|
|
78
|
+
lfm: `${outputRoot}.lfm`,
|
|
79
|
+
qm: `${outputRoot}.qm`,
|
|
80
|
+
min: `${outputRoot}.min`
|
|
81
|
+
};
|
|
82
|
+
const outputBuffers = {};
|
|
83
|
+
for (const key of Object.keys(outputs)) {
|
|
84
|
+
const outputBuffer = await (0, temp_io_1.deliverTempOutput)(outputs[key], {
|
|
85
|
+
output: options.outputs?.[key],
|
|
86
|
+
outputToBuffer
|
|
87
|
+
});
|
|
88
|
+
if (outputBuffer) {
|
|
89
|
+
outputBuffers[key] = outputBuffer;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
outputBuffers: Object.keys(outputBuffers).length ? outputBuffers : undefined,
|
|
94
|
+
stdout: result.stdout,
|
|
95
|
+
stderr: result.stderr
|
|
96
|
+
};
|
|
97
|
+
});
|
|
43
98
|
}
|
|
44
99
|
}
|
|
45
100
|
exports.Mindtct = Mindtct;
|
package/dist/src/nfiq.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AutoConvertConfig } from './image-convert';
|
|
2
|
+
import type { StreamInput, StreamInputOptions, StreamOutputOptions } from './temp-io';
|
|
1
3
|
export type NfiqRecordSelectors = {
|
|
2
4
|
fingerPosition?: string[];
|
|
3
5
|
impressionType?: string[];
|
|
@@ -30,7 +32,19 @@ export type NfiqResult = {
|
|
|
30
32
|
stdout: string;
|
|
31
33
|
stderr: string;
|
|
32
34
|
};
|
|
35
|
+
export type NfiqConstructorOptions = {
|
|
36
|
+
autoConvert?: boolean | AutoConvertConfig;
|
|
37
|
+
};
|
|
38
|
+
export type NfiqStreamOptions = Omit<NfiqOptions, 'ansiNistOutputPath'> & StreamInputOptions & {
|
|
39
|
+
ansiNistOutput?: StreamOutputOptions;
|
|
40
|
+
};
|
|
41
|
+
export type NfiqStreamResult = NfiqResult & {
|
|
42
|
+
ansiNistBuffer?: Buffer;
|
|
43
|
+
};
|
|
33
44
|
export declare class Nfiq {
|
|
45
|
+
private autoConvert;
|
|
46
|
+
constructor(options?: NfiqConstructorOptions);
|
|
34
47
|
version(): string;
|
|
35
48
|
score(imagePath: string, options?: NfiqOptions): NfiqResult;
|
|
49
|
+
scoreStream(input: StreamInput, options?: NfiqStreamOptions): Promise<NfiqStreamResult>;
|
|
36
50
|
}
|
package/dist/src/nfiq.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Nfiq = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
9
|
+
const image_convert_1 = require("./image-convert");
|
|
10
|
+
const temp_io_1 = require("./temp-io");
|
|
5
11
|
function buildRawAttr(raw) {
|
|
6
12
|
const attrs = [raw.width, raw.height, raw.depth];
|
|
7
13
|
if (raw.ppi != null) {
|
|
@@ -59,35 +65,79 @@ function parseScores(output) {
|
|
|
59
65
|
});
|
|
60
66
|
}
|
|
61
67
|
class Nfiq {
|
|
68
|
+
constructor(options = {}) {
|
|
69
|
+
this.autoConvert = (0, image_convert_1.normalizeAutoConvertConfig)(options.autoConvert);
|
|
70
|
+
}
|
|
62
71
|
version() {
|
|
63
72
|
const result = (0, nbis_runtime_1.runNbis)('nfiq', ['-version']);
|
|
64
73
|
(0, nbis_runtime_1.assertSuccess)(result, 'nfiq -version');
|
|
65
74
|
return result.stdout + result.stderr;
|
|
66
75
|
}
|
|
67
76
|
score(imagePath, options = {}) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
args
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
const prepared = (0, image_convert_1.prepareFingerprintImageSync)(imagePath, this.autoConvert);
|
|
78
|
+
try {
|
|
79
|
+
const args = [];
|
|
80
|
+
if (options.mode === 'verbose') {
|
|
81
|
+
args.push('-v');
|
|
82
|
+
}
|
|
83
|
+
if (options.oldBehavior) {
|
|
84
|
+
args.push('-o');
|
|
85
|
+
}
|
|
86
|
+
if (options.raw) {
|
|
87
|
+
args.push('-raw', buildRawAttr(options.raw));
|
|
88
|
+
}
|
|
89
|
+
addSelectors(args, options.selectors);
|
|
90
|
+
args.push(prepared.path);
|
|
91
|
+
if (options.ansiNistOutputPath) {
|
|
92
|
+
args.push(options.ansiNistOutputPath);
|
|
93
|
+
}
|
|
94
|
+
const result = (0, nbis_runtime_1.runNbis)('nfiq', args);
|
|
95
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'nfiq');
|
|
96
|
+
const output = result.stdout + result.stderr;
|
|
97
|
+
return {
|
|
98
|
+
scores: options.mode === 'verbose' ? [] : parseScores(output),
|
|
99
|
+
stdout: result.stdout,
|
|
100
|
+
stderr: result.stderr
|
|
101
|
+
};
|
|
77
102
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (options.ansiNistOutputPath) {
|
|
81
|
-
args.push(options.ansiNistOutputPath);
|
|
103
|
+
finally {
|
|
104
|
+
prepared.cleanup?.();
|
|
82
105
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
}
|
|
107
|
+
async scoreStream(input, options = {}) {
|
|
108
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
109
|
+
const imagePath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
110
|
+
const prepared = (0, image_convert_1.prepareFingerprintImageSync)(imagePath, this.autoConvert, tempDir);
|
|
111
|
+
const args = [];
|
|
112
|
+
if (options.mode === 'verbose') {
|
|
113
|
+
args.push('-v');
|
|
114
|
+
}
|
|
115
|
+
if (options.oldBehavior) {
|
|
116
|
+
args.push('-o');
|
|
117
|
+
}
|
|
118
|
+
if (options.raw) {
|
|
119
|
+
args.push('-raw', buildRawAttr(options.raw));
|
|
120
|
+
}
|
|
121
|
+
addSelectors(args, options.selectors);
|
|
122
|
+
args.push(prepared.path);
|
|
123
|
+
let ansiNistPath;
|
|
124
|
+
if (options.ansiNistOutput) {
|
|
125
|
+
ansiNistPath = path_1.default.join(tempDir, 'output.an2k');
|
|
126
|
+
args.push(ansiNistPath);
|
|
127
|
+
}
|
|
128
|
+
const result = (0, nbis_runtime_1.runNbis)('nfiq', args);
|
|
129
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'nfiq');
|
|
130
|
+
const output = result.stdout + result.stderr;
|
|
131
|
+
const ansiNistBuffer = ansiNistPath
|
|
132
|
+
? await (0, temp_io_1.deliverTempOutput)(ansiNistPath, options.ansiNistOutput)
|
|
133
|
+
: undefined;
|
|
134
|
+
return {
|
|
135
|
+
scores: options.mode === 'verbose' ? [] : parseScores(output),
|
|
136
|
+
stdout: result.stdout,
|
|
137
|
+
stderr: result.stderr,
|
|
138
|
+
ansiNistBuffer
|
|
139
|
+
};
|
|
140
|
+
});
|
|
91
141
|
}
|
|
92
142
|
}
|
|
93
143
|
exports.Nfiq = Nfiq;
|
package/dist/src/not2intr.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StreamInput, StreamIoOptions } from './temp-io';
|
|
1
2
|
export type Not2intrOptions = {
|
|
2
3
|
rawOut?: boolean;
|
|
3
4
|
yCbCr?: {
|
|
@@ -11,6 +12,12 @@ export type Not2intrResult = {
|
|
|
11
12
|
stdout: string;
|
|
12
13
|
stderr: string;
|
|
13
14
|
};
|
|
15
|
+
export type Not2intrStreamOptions = Not2intrOptions & StreamIoOptions;
|
|
16
|
+
export type Not2intrStreamResult = {
|
|
17
|
+
stdout: string;
|
|
18
|
+
stderr: string;
|
|
19
|
+
outputBuffer?: Buffer;
|
|
20
|
+
};
|
|
14
21
|
export declare class Not2intr {
|
|
15
22
|
version(): string;
|
|
16
23
|
convert(outputExtension: string, imagePath: string, rawIn: {
|
|
@@ -19,4 +26,10 @@ export declare class Not2intr {
|
|
|
19
26
|
depth: number;
|
|
20
27
|
ppi?: number;
|
|
21
28
|
}, options?: Not2intrOptions): Not2intrResult;
|
|
29
|
+
convertStream(outputExtension: string, input: StreamInput, rawIn: {
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
depth: number;
|
|
33
|
+
ppi?: number;
|
|
34
|
+
}, options?: Not2intrStreamOptions): Promise<Not2intrStreamResult>;
|
|
22
35
|
}
|
package/dist/src/not2intr.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Not2intr = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
9
|
+
const temp_io_1 = require("./temp-io");
|
|
9
10
|
function buildRawAttr(raw) {
|
|
10
11
|
const attrs = [raw.width, raw.height, raw.depth];
|
|
11
12
|
if (raw.ppi != null) {
|
|
@@ -44,5 +45,26 @@ class Not2intr {
|
|
|
44
45
|
stderr: result.stderr
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
async convertStream(outputExtension, input, rawIn, options = {}) {
|
|
49
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
50
|
+
const inputPath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
51
|
+
const args = [outputExtension, inputPath, buildRawAttr(rawIn)];
|
|
52
|
+
if (options.rawOut) {
|
|
53
|
+
args.push('-raw_out');
|
|
54
|
+
}
|
|
55
|
+
if (options.yCbCr) {
|
|
56
|
+
args.push('-YCbCr', buildYCbCr(options.yCbCr));
|
|
57
|
+
}
|
|
58
|
+
const result = (0, nbis_runtime_1.runNbis)('not2intr', args);
|
|
59
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'not2intr');
|
|
60
|
+
const outputPath = replaceExtension(inputPath, outputExtension);
|
|
61
|
+
const outputBuffer = await (0, temp_io_1.deliverTempOutput)(outputPath, options);
|
|
62
|
+
return {
|
|
63
|
+
stdout: result.stdout,
|
|
64
|
+
stderr: result.stderr,
|
|
65
|
+
outputBuffer
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
47
69
|
}
|
|
48
70
|
exports.Not2intr = Not2intr;
|
package/dist/src/rdjpgcom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StreamInput, StreamInputOptions } from './temp-io';
|
|
1
2
|
export type RdjpgcomOptions = {
|
|
2
3
|
verbose?: boolean;
|
|
3
4
|
};
|
|
@@ -5,7 +6,9 @@ export type RdjpgcomResult = {
|
|
|
5
6
|
stdout: string;
|
|
6
7
|
stderr: string;
|
|
7
8
|
};
|
|
9
|
+
export type RdjpgcomStreamOptions = RdjpgcomOptions & StreamInputOptions;
|
|
8
10
|
export declare class Rdjpgcom {
|
|
9
11
|
version(): string;
|
|
10
12
|
read(imagePath: string, options?: RdjpgcomOptions): RdjpgcomResult;
|
|
13
|
+
readStream(input: StreamInput, options?: RdjpgcomStreamOptions): Promise<RdjpgcomResult>;
|
|
11
14
|
}
|
package/dist/src/rdjpgcom.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rdjpgcom = void 0;
|
|
4
4
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
5
|
+
const temp_io_1 = require("./temp-io");
|
|
5
6
|
class Rdjpgcom {
|
|
6
7
|
version() {
|
|
7
8
|
const result = (0, nbis_runtime_1.runNbis)('rdjpgcom', ['-version']);
|
|
@@ -23,5 +24,21 @@ class Rdjpgcom {
|
|
|
23
24
|
stderr: result.stderr
|
|
24
25
|
};
|
|
25
26
|
}
|
|
27
|
+
async readStream(input, options = {}) {
|
|
28
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
29
|
+
const imagePath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
30
|
+
const args = [];
|
|
31
|
+
if (options.verbose) {
|
|
32
|
+
args.push('-verbose');
|
|
33
|
+
}
|
|
34
|
+
args.push(imagePath);
|
|
35
|
+
const result = (0, nbis_runtime_1.runNbis)('rdjpgcom', args);
|
|
36
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'rdjpgcom');
|
|
37
|
+
return {
|
|
38
|
+
stdout: result.stdout,
|
|
39
|
+
stderr: result.stderr
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
26
43
|
}
|
|
27
44
|
exports.Rdjpgcom = Rdjpgcom;
|
package/dist/src/rdwsqcom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StreamInput, StreamInputOptions } from './temp-io';
|
|
1
2
|
export type RdwsqcomResult = {
|
|
2
3
|
stdout: string;
|
|
3
4
|
stderr: string;
|
|
@@ -5,4 +6,5 @@ export type RdwsqcomResult = {
|
|
|
5
6
|
export declare class Rdwsqcom {
|
|
6
7
|
version(): string;
|
|
7
8
|
read(imagePath: string): RdwsqcomResult;
|
|
9
|
+
readStream(input: StreamInput, options?: StreamInputOptions): Promise<RdwsqcomResult>;
|
|
8
10
|
}
|
package/dist/src/rdwsqcom.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Rdwsqcom = void 0;
|
|
4
4
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
5
|
+
const temp_io_1 = require("./temp-io");
|
|
5
6
|
class Rdwsqcom {
|
|
6
7
|
version() {
|
|
7
8
|
const result = (0, nbis_runtime_1.runNbis)('rdwsqcom', ['-version']);
|
|
@@ -16,5 +17,16 @@ class Rdwsqcom {
|
|
|
16
17
|
stderr: result.stderr
|
|
17
18
|
};
|
|
18
19
|
}
|
|
20
|
+
async readStream(input, options = {}) {
|
|
21
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
22
|
+
const imagePath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
23
|
+
const result = (0, nbis_runtime_1.runNbis)('rdwsqcom', [imagePath]);
|
|
24
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'rdwsqcom');
|
|
25
|
+
return {
|
|
26
|
+
stdout: result.stdout,
|
|
27
|
+
stderr: result.stderr
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
32
|
exports.Rdwsqcom = Rdwsqcom;
|
package/dist/src/rgb2ycc.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StreamInput, StreamIoOptions } from './temp-io';
|
|
1
2
|
export type Rgb2yccOptions = {
|
|
2
3
|
rawIn?: {
|
|
3
4
|
width: number;
|
|
@@ -17,7 +18,14 @@ export type Rgb2yccResult = {
|
|
|
17
18
|
stdout: string;
|
|
18
19
|
stderr: string;
|
|
19
20
|
};
|
|
21
|
+
export type Rgb2yccStreamOptions = Rgb2yccOptions & StreamIoOptions;
|
|
22
|
+
export type Rgb2yccStreamResult = {
|
|
23
|
+
stdout: string;
|
|
24
|
+
stderr: string;
|
|
25
|
+
outputBuffer?: Buffer;
|
|
26
|
+
};
|
|
20
27
|
export declare class Rgb2ycc {
|
|
21
28
|
version(): string;
|
|
22
29
|
convert(outputExtension: string, imagePath: string, options?: Rgb2yccOptions): Rgb2yccResult;
|
|
30
|
+
convertStream(outputExtension: string, input: StreamInput, options?: Rgb2yccStreamOptions): Promise<Rgb2yccStreamResult>;
|
|
23
31
|
}
|
package/dist/src/rgb2ycc.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Rgb2ycc = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const nbis_runtime_1 = require("./nbis-runtime");
|
|
9
|
+
const temp_io_1 = require("./temp-io");
|
|
9
10
|
function buildRawAttr(raw) {
|
|
10
11
|
const attrs = [raw.width, raw.height, raw.depth];
|
|
11
12
|
if (raw.ppi != null) {
|
|
@@ -47,5 +48,29 @@ class Rgb2ycc {
|
|
|
47
48
|
stderr: result.stderr
|
|
48
49
|
};
|
|
49
50
|
}
|
|
51
|
+
async convertStream(outputExtension, input, options = {}) {
|
|
52
|
+
return (0, temp_io_1.withTempDir)(async (tempDir) => {
|
|
53
|
+
const inputPath = await (0, temp_io_1.writeTempInput)(tempDir, input, options);
|
|
54
|
+
const args = [outputExtension, inputPath];
|
|
55
|
+
if (options.rawIn) {
|
|
56
|
+
args.push('-raw_in', buildRawAttr(options.rawIn));
|
|
57
|
+
}
|
|
58
|
+
if (options.nonInterleaved) {
|
|
59
|
+
args.push('-nonintrlv');
|
|
60
|
+
}
|
|
61
|
+
if (options.yCbCr) {
|
|
62
|
+
args.push('-YCbCr', buildYCbCr(options.yCbCr));
|
|
63
|
+
}
|
|
64
|
+
const result = (0, nbis_runtime_1.runNbis)('rgb2ycc', args);
|
|
65
|
+
(0, nbis_runtime_1.assertSuccess)(result, 'rgb2ycc');
|
|
66
|
+
const outputPath = replaceExtension(inputPath, outputExtension);
|
|
67
|
+
const outputBuffer = await (0, temp_io_1.deliverTempOutput)(outputPath, options);
|
|
68
|
+
return {
|
|
69
|
+
stdout: result.stdout,
|
|
70
|
+
stderr: result.stderr,
|
|
71
|
+
outputBuffer
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
50
75
|
}
|
|
51
76
|
exports.Rgb2ycc = Rgb2ycc;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type StreamInput = Buffer | Uint8Array | NodeJS.ReadableStream;
|
|
2
|
+
export type StreamOutput = NodeJS.WritableStream;
|
|
3
|
+
export type StreamInputOptions = {
|
|
4
|
+
inputName?: string;
|
|
5
|
+
inputExtension?: string;
|
|
6
|
+
};
|
|
7
|
+
export type StreamOutputOptions = {
|
|
8
|
+
output?: StreamOutput;
|
|
9
|
+
outputToBuffer?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type StreamIoOptions = StreamInputOptions & StreamOutputOptions;
|
|
12
|
+
export declare function withTempDir<T>(fn: (tempDir: string) => Promise<T>): Promise<T>;
|
|
13
|
+
export declare function writeTempInput(tempDir: string, input: StreamInput, nameOrOptions?: string | StreamInputOptions): Promise<string>;
|
|
14
|
+
export declare function deliverTempOutput(outputPath: string, options?: StreamOutputOptions): Promise<Buffer | undefined>;
|
|
15
|
+
export declare function readFileIfExists(filePath: string): Promise<Buffer | undefined>;
|