@blazediff/core-native 5.0.0 → 5.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 CHANGED
@@ -19,10 +19,16 @@ The fastest single-threaded image diff in the world. Native Rust implementation
19
19
  - Cross-platform pre-built binaries (~700KB-900KB, no compilation required)
20
20
 
21
21
  **Vendored Libraries:**
22
- - [libspng](https://libspng.org/) - Fast PNG decoding/encoding with SIMD
22
+ - [libspng](https://libspng.org/) - Fast PNG decoding/encoding with SIMD (default)
23
23
  - [libjpeg-turbo](https://libjpeg-turbo.org/) - High-performance JPEG codec with SIMD
24
24
  - [qoi](https://github.com/aldanor/qoi-rust) - QOI (Quite OK Image) format for fast lossless compression
25
25
 
26
+ > **Experimental PNG codec:** the binaries also bundle an in-house Rust PNG codec
27
+ > ([`blazediff-png`](https://github.com/teimurjan/blazediff/tree/main/crates/blazediff-png)),
28
+ > faster than spng on every fixture with byte-exact decode parity. It's opt-in:
29
+ > set `BLAZEDIFF_PNG_ENABLED=1` to route PNG decode and stored-block (level 0) encode
30
+ > through it. spng stays the default.
31
+
26
32
  > **Note:** This package was previously published as [`@blazediff/bin`](https://www.npmjs.com/package/@blazediff/bin), which is now deprecated. Please use `@blazediff/core-native` instead.
27
33
 
28
34
  ## Installation
@@ -102,11 +108,17 @@ Compare two images (PNG or JPEG) and generate a diff image. Format is auto-detec
102
108
  <td>false</td>
103
109
  <td>Output only differences with transparent background</td>
104
110
  </tr>
111
+ <tr>
112
+ <td><code>diffColorAlt</code></td>
113
+ <td>[number, number, number]</td>
114
+ <td>diff color</td>
115
+ <td>Alternative RGB color for darkening differences</td>
116
+ </tr>
105
117
  <tr>
106
118
  <td><code>interpret</code></td>
107
119
  <td>boolean</td>
108
120
  <td>false</td>
109
- <td>Run structured interpretation after diff - adds <code>interpretation</code> to the result with detected change regions, classification, and a human-readable summary</td>
121
+ <td>Generate the diff image and structured interpretation in one pass, adding <code>interpretation</code> to the result</td>
110
122
  </tr>
111
123
  </table>
112
124
 
@@ -266,9 +278,11 @@ Options:
266
278
  -t, --threshold <THRESHOLD> Color difference threshold (0.0-1.0) [default: 0.1]
267
279
  -a, --antialiasing Enable anti-aliasing detection
268
280
  --diff-mask Output only differences (transparent background)
281
+ --diff-color-alt <R,G,B> Alternative RGB color for darkening differences
269
282
  -c, --compression <LEVEL> PNG compression level (0-9, 0=fastest, 9=smallest) [default: 0]
270
283
  -q, --quality <QUALITY> JPEG quality (1-100) [default: 90]
271
284
  --output-format <FORMAT> Output format (json or text) [default: json]
285
+ --interpret Generate diff output and structured interpretation
272
286
  -h, --help Print help
273
287
  -V, --version Print version
274
288
  ```
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ interface BlazeDiffOptions {
5
5
  antialiasing?: boolean;
6
6
  /** Output only differences with transparent background */
7
7
  diffMask?: boolean;
8
+ /** Alternative RGB color for darkening differences. Default: diff color */
9
+ diffColorAlt?: [number, number, number];
8
10
  /** PNG compression level (0-9, 0=fastest/largest, 9=slowest/smallest) */
9
11
  compression?: number;
10
12
  /** JPEG quality (1-100). Default: 90 */
package/dist/index.js CHANGED
@@ -50,6 +50,17 @@ var import_node_path = __toESM(require("path"));
50
50
  var import_node_url = require("url");
51
51
  var import_node_util = require("util");
52
52
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
53
+ function validateRgb(color) {
54
+ if (!color) return void 0;
55
+ if (color.length !== 3 || color.some(
56
+ (channel) => !Number.isInteger(channel) || channel < 0 || channel > 255
57
+ )) {
58
+ throw new RangeError(
59
+ "diffColorAlt must contain three integer RGB channels"
60
+ );
61
+ }
62
+ return color;
63
+ }
53
64
  var PLATFORM_PACKAGES = {
54
65
  "darwin-arm64": {
55
66
  packageName: "@blazediff/core-native-darwin-arm64",
@@ -140,6 +151,7 @@ function convertToNapiOptions(options) {
140
151
  threshold: options?.threshold,
141
152
  antialiasing: options?.antialiasing,
142
153
  diffMask: options?.diffMask,
154
+ diffColorAlt: validateRgb(options?.diffColorAlt),
143
155
  compression: options?.compression,
144
156
  quality: options?.quality,
145
157
  interpret: options?.interpret
@@ -199,13 +211,12 @@ function buildArgs(diffOutput, options) {
199
211
  if (options.threshold !== void 0)
200
212
  args.push(`--threshold=${options.threshold}`);
201
213
  if (options.antialiasing) args.push("--antialiasing");
202
- if (!useInterpret) {
203
- if (options.diffMask) args.push("--diff-mask");
204
- if (options.compression !== void 0)
205
- args.push(`--compression=${options.compression}`);
206
- if (options.quality !== void 0)
207
- args.push(`--quality=${options.quality}`);
208
- }
214
+ if (options.diffMask) args.push("--diff-mask");
215
+ const diffColorAlt = validateRgb(options.diffColorAlt);
216
+ if (diffColorAlt) args.push(`--diff-color-alt=${diffColorAlt.join(",")}`);
217
+ if (options.compression !== void 0)
218
+ args.push(`--compression=${options.compression}`);
219
+ if (options.quality !== void 0) args.push(`--quality=${options.quality}`);
209
220
  return args;
210
221
  }
211
222
  function parseJsonOutput(text) {
package/dist/index.mjs CHANGED
@@ -7,6 +7,17 @@ import path from "path";
7
7
  import { fileURLToPath } from "url";
8
8
  import { promisify } from "util";
9
9
  var execFileAsync = promisify(execFile);
10
+ function validateRgb(color) {
11
+ if (!color) return void 0;
12
+ if (color.length !== 3 || color.some(
13
+ (channel) => !Number.isInteger(channel) || channel < 0 || channel > 255
14
+ )) {
15
+ throw new RangeError(
16
+ "diffColorAlt must contain three integer RGB channels"
17
+ );
18
+ }
19
+ return color;
20
+ }
10
21
  var PLATFORM_PACKAGES = {
11
22
  "darwin-arm64": {
12
23
  packageName: "@blazediff/core-native-darwin-arm64",
@@ -97,6 +108,7 @@ function convertToNapiOptions(options) {
97
108
  threshold: options?.threshold,
98
109
  antialiasing: options?.antialiasing,
99
110
  diffMask: options?.diffMask,
111
+ diffColorAlt: validateRgb(options?.diffColorAlt),
100
112
  compression: options?.compression,
101
113
  quality: options?.quality,
102
114
  interpret: options?.interpret
@@ -156,13 +168,12 @@ function buildArgs(diffOutput, options) {
156
168
  if (options.threshold !== void 0)
157
169
  args.push(`--threshold=${options.threshold}`);
158
170
  if (options.antialiasing) args.push("--antialiasing");
159
- if (!useInterpret) {
160
- if (options.diffMask) args.push("--diff-mask");
161
- if (options.compression !== void 0)
162
- args.push(`--compression=${options.compression}`);
163
- if (options.quality !== void 0)
164
- args.push(`--quality=${options.quality}`);
165
- }
171
+ if (options.diffMask) args.push("--diff-mask");
172
+ const diffColorAlt = validateRgb(options.diffColorAlt);
173
+ if (diffColorAlt) args.push(`--diff-color-alt=${diffColorAlt.join(",")}`);
174
+ if (options.compression !== void 0)
175
+ args.push(`--compression=${options.compression}`);
176
+ if (options.quality !== void 0) args.push(`--quality=${options.quality}`);
166
177
  return args;
167
178
  }
168
179
  function parseJsonOutput(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazediff/core-native",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Native Rust binaries for blazediff - the fastest image diff in the world",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -20,12 +20,12 @@
20
20
  "dist"
21
21
  ],
22
22
  "optionalDependencies": {
23
- "@blazediff/core-native-darwin-arm64": "5.0.0",
24
- "@blazediff/core-native-darwin-x64": "5.0.0",
25
- "@blazediff/core-native-linux-arm64": "5.0.0",
26
- "@blazediff/core-native-linux-x64": "5.0.0",
27
- "@blazediff/core-native-win32-arm64": "5.0.0",
28
- "@blazediff/core-native-win32-x64": "5.0.0"
23
+ "@blazediff/core-native-darwin-arm64": "5.2.0",
24
+ "@blazediff/core-native-darwin-x64": "5.2.0",
25
+ "@blazediff/core-native-linux-arm64": "5.2.0",
26
+ "@blazediff/core-native-linux-x64": "5.2.0",
27
+ "@blazediff/core-native-win32-arm64": "5.2.0",
28
+ "@blazediff/core-native-win32-x64": "5.2.0"
29
29
  },
30
30
  "keywords": [
31
31
  "image",