@blazediff/cli 3.0.0 → 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/dist/cli.js CHANGED
@@ -40,24 +40,27 @@ __export(core_native_exports, {
40
40
  });
41
41
  function printUsage() {
42
42
  console.log(`
43
- Usage: blazediff-cli core-native <image1> <image2> <output> [options]
43
+ Usage: blazediff-cli core-native <image1> <image2> [output] [options]
44
44
 
45
45
  Arguments:
46
46
  image1 Path to the first image
47
47
  image2 Path to the second image
48
- output Path for the diff image output
48
+ output Path for the diff output (optional)
49
49
 
50
50
  Options:
51
51
  -t, --threshold <num> Color difference threshold (0 to 1, default: 0.1)
52
52
  -a, --antialiasing Enable anti-aliasing detection
53
53
  --diff-mask Output only differences (transparent background)
54
54
  -c, --compression <num> PNG compression level (0-9, default: 0)
55
+ --interpret Run structured interpretation (region detection + classification)
56
+ --output-format <fmt> Output format: png (default) or html (interpret report)
55
57
  -h, --help Show this help message
56
58
 
57
59
  Examples:
58
60
  blazediff-cli core-native image1.png image2.png diff.png
59
61
  blazediff-cli core-native image1.png image2.png diff.png -t 0.05 -a
60
- blazediff-cli core-native image1.png image2.png diff.png --threshold 0.2 --antialiasing
62
+ blazediff-cli core-native image1.png image2.png --interpret
63
+ blazediff-cli core-native image1.png image2.png report.html --output-format html
61
64
  `);
62
65
  }
63
66
  async function main() {
@@ -67,16 +70,21 @@ async function main() {
67
70
  printUsage();
68
71
  process.exit(0);
69
72
  }
70
- if (args.length < 3) {
71
- console.error("Error: Two image paths and an output path are required");
73
+ if (args.length < 2) {
74
+ console.error("Error: Two image paths are required");
72
75
  printUsage();
73
76
  process.exit(1);
74
77
  }
75
78
  const image1 = args[0];
76
79
  const image2 = args[1];
77
- const output = args[2];
78
80
  const options = {};
79
- for (let i3 = 3; i3 < args.length; i3++) {
81
+ let output;
82
+ let optStart = 2;
83
+ if (args.length > 2 && !args[2].startsWith("-")) {
84
+ output = args[2];
85
+ optStart = 3;
86
+ }
87
+ for (let i3 = optStart; i3 < args.length; i3++) {
80
88
  const arg = args[i3];
81
89
  const nextArg = args[i3 + 1];
82
90
  switch (arg) {
@@ -113,6 +121,19 @@ async function main() {
113
121
  i3++;
114
122
  }
115
123
  break;
124
+ case "--interpret":
125
+ options.interpret = true;
126
+ break;
127
+ case "--output-format":
128
+ if (nextArg === "png" || nextArg === "html") {
129
+ options.outputFormat = nextArg;
130
+ i3++;
131
+ } else {
132
+ throw new Error(
133
+ `Invalid output format: ${nextArg}. Must be "png" or "html"`
134
+ );
135
+ }
136
+ break;
116
137
  default:
117
138
  console.error(`Unknown option: ${arg}`);
118
139
  printUsage();
@@ -120,6 +141,17 @@ async function main() {
120
141
  }
121
142
  }
122
143
  const startTime = performance.now();
144
+ if (options.interpret && !output) {
145
+ const result2 = await (0, import_core_native.interpret)(image1, image2, {
146
+ threshold: options.threshold,
147
+ antialiasing: options.antialiasing
148
+ });
149
+ const duration2 = performance.now() - startTime;
150
+ console.log(`completed in: ${duration2.toFixed(2)}ms`);
151
+ console.log(JSON.stringify(result2, null, 2));
152
+ process.exit(result2.diffPercentage === 0 ? 0 : 1);
153
+ return;
154
+ }
123
155
  const result = await (0, import_core_native.compare)(image1, image2, output, options);
124
156
  const duration = performance.now() - startTime;
125
157
  console.log(`completed in: ${duration.toFixed(2)}ms`);
@@ -138,7 +170,12 @@ async function main() {
138
170
  if (result.reason === "pixel-diff") {
139
171
  console.log(`different pixels: ${result.diffCount}`);
140
172
  console.log(`error: ${result.diffPercentage.toFixed(2)}%`);
141
- console.log(`diff image: ${output}`);
173
+ if (output) {
174
+ console.log(`diff output: ${output}`);
175
+ }
176
+ if ("interpretation" in result && result.interpretation) {
177
+ console.log(JSON.stringify(result.interpretation, null, 2));
178
+ }
142
179
  process.exit(1);
143
180
  }
144
181
  } catch (error) {
@@ -10689,6 +10726,7 @@ Examples:
10689
10726
  blazediff-cli ssim image1.png image2.png -o ssim-map.png
10690
10727
  blazediff-cli msssim image1.png image2.png
10691
10728
  blazediff-cli hitchhikers-ssim image1.png image2.png
10729
+ blazediff-cli image1.png image2.png --interpret
10692
10730
 
10693
10731
  # Default command (diff) if no command specified
10694
10732
  blazediff-cli image1.png image2.png
@@ -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> <output> [options]
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 image output
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 diff.png --threshold 0.2 --antialiasing
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 < 3) {
58
- console.error("Error: Two image paths and an output path are required");
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
- for (let i = 3; i < args.length; i++) {
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
- console.log(`diff image: ${output}`);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazediff/cli",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Command-line interface for the blazediff image comparison library",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -37,7 +37,7 @@
37
37
  "homepage": "https://blazediff.dev",
38
38
  "license": "MIT",
39
39
  "dependencies": {
40
- "@blazediff/core-native": "4.0.0",
40
+ "@blazediff/core-native": "4.1.0",
41
41
  "@blazediff/core": "1.9.1",
42
42
  "@blazediff/gmsd": "1.7.1",
43
43
  "@blazediff/codec-pngjs": "3.0.0",