@blazediff/cli 2.1.4 → 3.1.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 +9 -8
- package/dist/cli.js +1223 -811
- package/dist/commands/core-native.js +45 -8
- package/dist/commands/core.js +841 -479
- package/dist/commands/gmsd.js +831 -469
- package/dist/commands/hitchhikers-ssim.js +819 -457
- package/dist/commands/msssim.js +839 -475
- package/dist/commands/ssim.js +853 -489
- package/dist/index.d.ts +6 -6
- package/package.json +3 -2
|
@@ -27,24 +27,27 @@ module.exports = __toCommonJS(core_native_exports);
|
|
|
27
27
|
var import_core_native = require("@blazediff/core-native");
|
|
28
28
|
function printUsage() {
|
|
29
29
|
console.log(`
|
|
30
|
-
Usage: blazediff-cli core-native <image1> <image2>
|
|
30
|
+
Usage: blazediff-cli core-native <image1> <image2> [output] [options]
|
|
31
31
|
|
|
32
32
|
Arguments:
|
|
33
33
|
image1 Path to the first image
|
|
34
34
|
image2 Path to the second image
|
|
35
|
-
output Path for the diff
|
|
35
|
+
output Path for the diff output (optional)
|
|
36
36
|
|
|
37
37
|
Options:
|
|
38
38
|
-t, --threshold <num> Color difference threshold (0 to 1, default: 0.1)
|
|
39
39
|
-a, --antialiasing Enable anti-aliasing detection
|
|
40
40
|
--diff-mask Output only differences (transparent background)
|
|
41
41
|
-c, --compression <num> PNG compression level (0-9, default: 0)
|
|
42
|
+
--interpret Run structured interpretation (region detection + classification)
|
|
43
|
+
--output-format <fmt> Output format: png (default) or html (interpret report)
|
|
42
44
|
-h, --help Show this help message
|
|
43
45
|
|
|
44
46
|
Examples:
|
|
45
47
|
blazediff-cli core-native image1.png image2.png diff.png
|
|
46
48
|
blazediff-cli core-native image1.png image2.png diff.png -t 0.05 -a
|
|
47
|
-
blazediff-cli core-native image1.png image2.png
|
|
49
|
+
blazediff-cli core-native image1.png image2.png --interpret
|
|
50
|
+
blazediff-cli core-native image1.png image2.png report.html --output-format html
|
|
48
51
|
`);
|
|
49
52
|
}
|
|
50
53
|
async function main() {
|
|
@@ -54,16 +57,21 @@ async function main() {
|
|
|
54
57
|
printUsage();
|
|
55
58
|
process.exit(0);
|
|
56
59
|
}
|
|
57
|
-
if (args.length <
|
|
58
|
-
console.error("Error: Two image paths
|
|
60
|
+
if (args.length < 2) {
|
|
61
|
+
console.error("Error: Two image paths are required");
|
|
59
62
|
printUsage();
|
|
60
63
|
process.exit(1);
|
|
61
64
|
}
|
|
62
65
|
const image1 = args[0];
|
|
63
66
|
const image2 = args[1];
|
|
64
|
-
const output = args[2];
|
|
65
67
|
const options = {};
|
|
66
|
-
|
|
68
|
+
let output;
|
|
69
|
+
let optStart = 2;
|
|
70
|
+
if (args.length > 2 && !args[2].startsWith("-")) {
|
|
71
|
+
output = args[2];
|
|
72
|
+
optStart = 3;
|
|
73
|
+
}
|
|
74
|
+
for (let i = optStart; i < args.length; i++) {
|
|
67
75
|
const arg = args[i];
|
|
68
76
|
const nextArg = args[i + 1];
|
|
69
77
|
switch (arg) {
|
|
@@ -100,6 +108,19 @@ async function main() {
|
|
|
100
108
|
i++;
|
|
101
109
|
}
|
|
102
110
|
break;
|
|
111
|
+
case "--interpret":
|
|
112
|
+
options.interpret = true;
|
|
113
|
+
break;
|
|
114
|
+
case "--output-format":
|
|
115
|
+
if (nextArg === "png" || nextArg === "html") {
|
|
116
|
+
options.outputFormat = nextArg;
|
|
117
|
+
i++;
|
|
118
|
+
} else {
|
|
119
|
+
throw new Error(
|
|
120
|
+
`Invalid output format: ${nextArg}. Must be "png" or "html"`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
103
124
|
default:
|
|
104
125
|
console.error(`Unknown option: ${arg}`);
|
|
105
126
|
printUsage();
|
|
@@ -107,6 +128,17 @@ async function main() {
|
|
|
107
128
|
}
|
|
108
129
|
}
|
|
109
130
|
const startTime = performance.now();
|
|
131
|
+
if (options.interpret && !output) {
|
|
132
|
+
const result2 = await (0, import_core_native.interpret)(image1, image2, {
|
|
133
|
+
threshold: options.threshold,
|
|
134
|
+
antialiasing: options.antialiasing
|
|
135
|
+
});
|
|
136
|
+
const duration2 = performance.now() - startTime;
|
|
137
|
+
console.log(`completed in: ${duration2.toFixed(2)}ms`);
|
|
138
|
+
console.log(JSON.stringify(result2, null, 2));
|
|
139
|
+
process.exit(result2.diffPercentage === 0 ? 0 : 1);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
110
142
|
const result = await (0, import_core_native.compare)(image1, image2, output, options);
|
|
111
143
|
const duration = performance.now() - startTime;
|
|
112
144
|
console.log(`completed in: ${duration.toFixed(2)}ms`);
|
|
@@ -125,7 +157,12 @@ async function main() {
|
|
|
125
157
|
if (result.reason === "pixel-diff") {
|
|
126
158
|
console.log(`different pixels: ${result.diffCount}`);
|
|
127
159
|
console.log(`error: ${result.diffPercentage.toFixed(2)}%`);
|
|
128
|
-
|
|
160
|
+
if (output) {
|
|
161
|
+
console.log(`diff output: ${output}`);
|
|
162
|
+
}
|
|
163
|
+
if ("interpretation" in result && result.interpretation) {
|
|
164
|
+
console.log(JSON.stringify(result.interpretation, null, 2));
|
|
165
|
+
}
|
|
129
166
|
process.exit(1);
|
|
130
167
|
}
|
|
131
168
|
} catch (error) {
|