@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
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>
|
|
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
|
|
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
|
|
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,18 +70,23 @@ async function main() {
|
|
|
67
70
|
printUsage();
|
|
68
71
|
process.exit(0);
|
|
69
72
|
}
|
|
70
|
-
if (args.length <
|
|
71
|
-
console.error("Error: Two image paths
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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++) {
|
|
88
|
+
const arg = args[i3];
|
|
89
|
+
const nextArg = args[i3 + 1];
|
|
82
90
|
switch (arg) {
|
|
83
91
|
case "-t":
|
|
84
92
|
case "--threshold":
|
|
@@ -90,7 +98,7 @@ async function main() {
|
|
|
90
98
|
);
|
|
91
99
|
}
|
|
92
100
|
options.threshold = threshold;
|
|
93
|
-
|
|
101
|
+
i3++;
|
|
94
102
|
}
|
|
95
103
|
break;
|
|
96
104
|
case "-a":
|
|
@@ -110,7 +118,20 @@ async function main() {
|
|
|
110
118
|
);
|
|
111
119
|
}
|
|
112
120
|
options.compression = compression;
|
|
113
|
-
|
|
121
|
+
i3++;
|
|
122
|
+
}
|
|
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
|
+
);
|
|
114
135
|
}
|
|
115
136
|
break;
|
|
116
137
|
default:
|
|
@@ -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
|
-
|
|
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) {
|
|
@@ -161,112 +198,112 @@ var init_core_native = __esm({
|
|
|
161
198
|
});
|
|
162
199
|
|
|
163
200
|
// ../core/dist/index.mjs
|
|
164
|
-
function g(
|
|
165
|
-
if (!_(
|
|
166
|
-
if (
|
|
167
|
-
if (
|
|
168
|
-
if (y && typeof Buffer < "u" && Buffer.compare &&
|
|
169
|
-
if (t && !b) for (let A = 0; A < e * o2; A++) L(
|
|
201
|
+
function g(n3, r, t, e, o2, { threshold: f2 = 0.1, alpha: c3 = 0.1, aaColor: s = [255, 255, 0], diffColor: a2 = [255, 0, 0], includeAA: U3, diffColorAlt: O2, diffMask: b, fastBufferCheck: y = true } = {}) {
|
|
202
|
+
if (!_(n3) || !_(r) || t && !_(t)) throw new Error("Image data: Uint8Array, Uint8ClampedArray or Buffer expected.");
|
|
203
|
+
if (n3.length !== r.length || t && t.length !== n3.length) throw new Error(`Image sizes do not match. Image 1 size: ${n3.length}, image 2 size: ${r.length}`);
|
|
204
|
+
if (n3.length !== e * o2 * 4) throw new Error(`Image data size does not match width/height. Expecting ${e * o2 * 4}. Got ${n3.length}`);
|
|
205
|
+
if (y && typeof Buffer < "u" && Buffer.compare && n3 instanceof Uint8Array && r instanceof Uint8Array && Buffer.compare(n3, r) === 0) {
|
|
206
|
+
if (t && !b) for (let A = 0; A < e * o2; A++) L(n3, A * 4, c3, t);
|
|
170
207
|
return 0;
|
|
171
208
|
}
|
|
172
|
-
let
|
|
173
|
-
for (let A = 0; A < I2; A++) for (let R = 0; R <
|
|
174
|
-
let
|
|
209
|
+
let m3 = e * o2, u = new Uint32Array(n3.buffer, n3.byteOffset, m3), d2 = new Uint32Array(r.buffer, r.byteOffset, m3), l2 = tn(e, o2), i3 = Math.ceil(e / l2), I2 = Math.ceil(o2 / l2), z2 = i3 * I2, x = new Uint16Array(z2), M = 35215 * f2 * f2, B = 0;
|
|
210
|
+
for (let A = 0; A < I2; A++) for (let R = 0; R < i3; R++) {
|
|
211
|
+
let p3 = R * l2, v = A * l2, D3 = Math.min(p3 + l2, e), P4 = Math.min(v + l2, o2), $ = false;
|
|
175
212
|
n: for (let C3 = v; C3 < P4; C3++) {
|
|
176
213
|
let Y = C3 * e;
|
|
177
|
-
for (let G =
|
|
214
|
+
for (let G = p3; G < D3; G++) {
|
|
178
215
|
let E3 = Y + G;
|
|
179
216
|
if (u[E3] === d2[E3]) continue;
|
|
180
|
-
let S3 = E3 * 4, X2 = N(
|
|
217
|
+
let S3 = E3 * 4, X2 = N(n3, r, S3, S3);
|
|
181
218
|
if (Math.abs(X2) > M) {
|
|
182
219
|
$ = true;
|
|
183
220
|
break n;
|
|
184
221
|
}
|
|
185
222
|
}
|
|
186
223
|
}
|
|
187
|
-
if ($) x[B++] = A *
|
|
224
|
+
if ($) x[B++] = A * i3 + R;
|
|
188
225
|
else if (t && !b) for (let C3 = v; C3 < P4; C3++) {
|
|
189
226
|
let Y = C3 * e;
|
|
190
|
-
for (let G =
|
|
227
|
+
for (let G = p3; G < D3; G++) {
|
|
191
228
|
let E3 = Y + G;
|
|
192
|
-
L(
|
|
229
|
+
L(n3, E3 * 4, c3, t);
|
|
193
230
|
}
|
|
194
231
|
}
|
|
195
232
|
}
|
|
196
233
|
if (B === 0) return 0;
|
|
197
|
-
let [F2, J, K2] =
|
|
234
|
+
let [F2, J, K2] = s, [Q2, W2, Z2] = a2, [k, w, h4] = O2 || a2, T = 0;
|
|
198
235
|
for (let A = 0; A < B; A++) {
|
|
199
|
-
let R = x[A],
|
|
236
|
+
let R = x[A], p3 = R % i3, v = R / i3 | 0, D3 = p3 * l2, P4 = v * l2, $ = Math.min(D3 + l2, e), C3 = Math.min(P4 + l2, o2);
|
|
200
237
|
for (let Y = P4; Y < C3; Y++) {
|
|
201
238
|
let G = Y * e;
|
|
202
239
|
for (let E3 = D3; E3 < $; E3++) {
|
|
203
240
|
let S3 = G + E3, X2 = S3 * 4;
|
|
204
241
|
if (u[S3] === d2[S3]) {
|
|
205
|
-
t && !b && L(
|
|
242
|
+
t && !b && L(n3, X2, c3, t);
|
|
206
243
|
continue;
|
|
207
244
|
}
|
|
208
|
-
let H3 = N(
|
|
209
|
-
Math.abs(H3) > M ? !U3 && (j(
|
|
245
|
+
let H3 = N(n3, r, X2, X2);
|
|
246
|
+
Math.abs(H3) > M ? !U3 && (j(n3, E3, Y, e, o2, u, d2) || j(r, E3, Y, e, o2, d2, u)) ? t && !b && V(t, X2, F2, J, K2) : (t && (H3 < 0 ? V(t, X2, k, w, h4) : V(t, X2, Q2, W2, Z2)), T++) : t && !b && L(n3, X2, c3, t);
|
|
210
247
|
}
|
|
211
248
|
}
|
|
212
249
|
}
|
|
213
250
|
return T;
|
|
214
251
|
}
|
|
215
|
-
function _(
|
|
216
|
-
return ArrayBuffer.isView(
|
|
252
|
+
function _(n3) {
|
|
253
|
+
return ArrayBuffer.isView(n3) && n3.BYTES_PER_ELEMENT === 1;
|
|
217
254
|
}
|
|
218
|
-
function tn(
|
|
219
|
-
let t =
|
|
255
|
+
function tn(n3, r) {
|
|
256
|
+
let t = n3 * r, e = Math.sqrt(t) / 100, o2 = 16 * Math.sqrt(e), f2 = Math.log(o2) * nn;
|
|
220
257
|
return 1 << Math.round(f2);
|
|
221
258
|
}
|
|
222
|
-
function N(
|
|
223
|
-
let o2 =
|
|
224
|
-
if (!y && !
|
|
225
|
-
if (
|
|
259
|
+
function N(n3, r, t, e) {
|
|
260
|
+
let o2 = n3[t], f2 = n3[t + 1], c3 = n3[t + 2], s = n3[t + 3], a2 = r[e], U3 = r[e + 1], O2 = r[e + 2], b = r[e + 3], y = o2 - a2, m3 = f2 - U3, u = c3 - O2, d2 = s - b;
|
|
261
|
+
if (!y && !m3 && !u && !d2) return 0;
|
|
262
|
+
if (s < 255 || b < 255) {
|
|
226
263
|
let x = 48 + 159 * (t % 2), M = 48 + 159 * ((t / 1.618033988749895 | 0) & 1), B = 48 + 159 * ((t / 2.618033988749895 | 0) & 1);
|
|
227
|
-
y = (o2 *
|
|
264
|
+
y = (o2 * s - a2 * b - x * d2) / 255, m3 = (f2 * s - U3 * b - M * d2) / 255, u = (c3 * s - O2 * b - B * d2) / 255;
|
|
228
265
|
}
|
|
229
|
-
let
|
|
230
|
-
return
|
|
266
|
+
let l2 = y * 0.29889531 + m3 * 0.58662247 + u * 0.11448223, i3 = y * 0.59597799 - m3 * 0.2741761 - u * 0.32180189, I2 = y * 0.21147017 - m3 * 0.52261711 + u * 0.31114694, z2 = 0.5053 * l2 * l2 + 0.299 * i3 * i3 + 0.1957 * I2 * I2;
|
|
267
|
+
return l2 > 0 ? -z2 : z2;
|
|
231
268
|
}
|
|
232
|
-
function rn(
|
|
233
|
-
let o2 =
|
|
234
|
-
if (!y && !
|
|
235
|
-
if (
|
|
236
|
-
let
|
|
237
|
-
y = (o2 *
|
|
238
|
-
}
|
|
239
|
-
return y * 0.29889531 +
|
|
269
|
+
function rn(n3, r, t, e) {
|
|
270
|
+
let o2 = n3[t], f2 = n3[t + 1], c3 = n3[t + 2], s = n3[t + 3], a2 = r[e], U3 = r[e + 1], O2 = r[e + 2], b = r[e + 3], y = o2 - a2, m3 = f2 - U3, u = c3 - O2, d2 = s - b;
|
|
271
|
+
if (!y && !m3 && !u && !d2) return 0;
|
|
272
|
+
if (s < 255 || b < 255) {
|
|
273
|
+
let i3 = 48 + 159 * (t % 2), I2 = 48 + 159 * ((t / 1.618033988749895 | 0) & 1), z2 = 48 + 159 * ((t / 2.618033988749895 | 0) & 1);
|
|
274
|
+
y = (o2 * s - a2 * b - i3 * d2) / 255, m3 = (f2 * s - U3 * b - I2 * d2) / 255, u = (c3 * s - O2 * b - z2 * d2) / 255;
|
|
275
|
+
}
|
|
276
|
+
return y * 0.29889531 + m3 * 0.58662247 + u * 0.11448223;
|
|
240
277
|
}
|
|
241
|
-
function j(
|
|
242
|
-
let
|
|
243
|
-
for (let x =
|
|
278
|
+
function j(n3, r, t, e, o2, f2, c3) {
|
|
279
|
+
let s = Math.max(r - 1, 0), a2 = Math.max(t - 1, 0), U3 = Math.min(r + 1, e - 1), O2 = Math.min(t + 1, o2 - 1), y = (t * e + r) * 4, m3 = r === s || r === U3 || t === a2 || t === O2 ? 1 : 0, u = 0, d2 = 0, l2 = 0, i3 = 0, I2 = 0, z2 = 0;
|
|
280
|
+
for (let x = s; x <= U3; x++) for (let M = a2; M <= O2; M++) {
|
|
244
281
|
if (x === r && M === t) continue;
|
|
245
|
-
let B = rn(
|
|
282
|
+
let B = rn(n3, n3, y, (M * e + x) * 4);
|
|
246
283
|
if (B === 0) {
|
|
247
|
-
if (
|
|
248
|
-
} else B < u ? (u = B,
|
|
284
|
+
if (m3++, m3 > 2) return false;
|
|
285
|
+
} else B < u ? (u = B, l2 = x, i3 = M) : B > d2 && (d2 = B, I2 = x, z2 = M);
|
|
249
286
|
}
|
|
250
|
-
return u === 0 || d2 === 0 ? false : q(f2,
|
|
287
|
+
return u === 0 || d2 === 0 ? false : q(f2, l2, i3, e, o2) && q(c3, l2, i3, e, o2) || q(f2, I2, z2, e, o2) && q(c3, I2, z2, e, o2);
|
|
251
288
|
}
|
|
252
|
-
function q(
|
|
253
|
-
let f2 = t * e + r,
|
|
289
|
+
function q(n3, r, t, e, o2) {
|
|
290
|
+
let f2 = t * e + r, c3 = n3[f2], s = r === 0 || r === e - 1 || t === 0 || t === o2 - 1 ? 1 : 0;
|
|
254
291
|
if (t > 0) {
|
|
255
292
|
let a2 = f2 - e;
|
|
256
|
-
r > 0 &&
|
|
293
|
+
r > 0 && n3[a2 - 1] === c3 && s++, n3[a2] === c3 && s++, r < e - 1 && n3[a2 + 1] === c3 && s++;
|
|
257
294
|
}
|
|
258
|
-
if (r > 0 &&
|
|
295
|
+
if (r > 0 && n3[f2 - 1] === c3 && s++, r < e - 1 && n3[f2 + 1] === c3 && s++, t < o2 - 1) {
|
|
259
296
|
let a2 = f2 + e;
|
|
260
|
-
r > 0 &&
|
|
297
|
+
r > 0 && n3[a2 - 1] === c3 && s++, n3[a2] === c3 && s++, r < e - 1 && n3[a2 + 1] === c3 && s++;
|
|
261
298
|
}
|
|
262
|
-
return
|
|
299
|
+
return s > 2;
|
|
263
300
|
}
|
|
264
|
-
function L(
|
|
265
|
-
let o2 = 255 + (
|
|
301
|
+
function L(n3, r, t, e) {
|
|
302
|
+
let o2 = 255 + (n3[r] * 0.29889531 + n3[r + 1] * 0.58662247 + n3[r + 2] * 0.11448223 - 255) * t * n3[r + 3] / 255;
|
|
266
303
|
V(e, r, o2, o2, o2);
|
|
267
304
|
}
|
|
268
|
-
function V(
|
|
269
|
-
|
|
305
|
+
function V(n3, r, t, e, o2) {
|
|
306
|
+
n3[r + 0] = t, n3[r + 1] = e, n3[r + 2] = o2, n3[r + 3] = 255;
|
|
270
307
|
}
|
|
271
308
|
var nn, on;
|
|
272
309
|
var init_dist = __esm({
|
|
@@ -462,8 +499,8 @@ var require_interlace = __commonJS({
|
|
|
462
499
|
let yLeftOver = height % 8;
|
|
463
500
|
let xRepeats = (width - xLeftOver) / 8;
|
|
464
501
|
let yRepeats = (height - yLeftOver) / 8;
|
|
465
|
-
for (let
|
|
466
|
-
let pass = imagePasses[
|
|
502
|
+
for (let i3 = 0; i3 < imagePasses.length; i3++) {
|
|
503
|
+
let pass = imagePasses[i3];
|
|
467
504
|
let passWidth = xRepeats * pass.x.length;
|
|
468
505
|
let passHeight = yRepeats * pass.y.length;
|
|
469
506
|
for (let j3 = 0; j3 < pass.x.length; j3++) {
|
|
@@ -481,7 +518,7 @@ var require_interlace = __commonJS({
|
|
|
481
518
|
}
|
|
482
519
|
}
|
|
483
520
|
if (passWidth > 0 && passHeight > 0) {
|
|
484
|
-
images.push({ width: passWidth, height: passHeight, index:
|
|
521
|
+
images.push({ width: passWidth, height: passHeight, index: i3 });
|
|
485
522
|
}
|
|
486
523
|
}
|
|
487
524
|
return images;
|
|
@@ -544,10 +581,10 @@ var require_filter_parse = __commonJS({
|
|
|
544
581
|
this._images = [];
|
|
545
582
|
if (interlace) {
|
|
546
583
|
let passes = interlaceUtils.getImagePasses(width, height);
|
|
547
|
-
for (let
|
|
584
|
+
for (let i3 = 0; i3 < passes.length; i3++) {
|
|
548
585
|
this._images.push({
|
|
549
|
-
byteWidth: getByteWidth(passes[
|
|
550
|
-
height: passes[
|
|
586
|
+
byteWidth: getByteWidth(passes[i3].width, bpp, depth),
|
|
587
|
+
height: passes[i3].height,
|
|
551
588
|
lineIndex: 0
|
|
552
589
|
});
|
|
553
590
|
}
|
|
@@ -726,8 +763,8 @@ var require_crc = __commonJS({
|
|
|
726
763
|
"use strict";
|
|
727
764
|
var crcTable = [];
|
|
728
765
|
(function() {
|
|
729
|
-
for (let
|
|
730
|
-
let currentCrc =
|
|
766
|
+
for (let i3 = 0; i3 < 256; i3++) {
|
|
767
|
+
let currentCrc = i3;
|
|
731
768
|
for (let j3 = 0; j3 < 8; j3++) {
|
|
732
769
|
if (currentCrc & 1) {
|
|
733
770
|
currentCrc = 3988292384 ^ currentCrc >>> 1;
|
|
@@ -735,15 +772,15 @@ var require_crc = __commonJS({
|
|
|
735
772
|
currentCrc = currentCrc >>> 1;
|
|
736
773
|
}
|
|
737
774
|
}
|
|
738
|
-
crcTable[
|
|
775
|
+
crcTable[i3] = currentCrc;
|
|
739
776
|
}
|
|
740
777
|
})();
|
|
741
778
|
var CrcCalculator = module2.exports = function() {
|
|
742
779
|
this._crc = -1;
|
|
743
780
|
};
|
|
744
781
|
CrcCalculator.prototype.write = function(data) {
|
|
745
|
-
for (let
|
|
746
|
-
this._crc = crcTable[(this._crc ^ data[
|
|
782
|
+
for (let i3 = 0; i3 < data.length; i3++) {
|
|
783
|
+
this._crc = crcTable[(this._crc ^ data[i3]) & 255] ^ this._crc >>> 8;
|
|
747
784
|
}
|
|
748
785
|
return true;
|
|
749
786
|
};
|
|
@@ -752,8 +789,8 @@ var require_crc = __commonJS({
|
|
|
752
789
|
};
|
|
753
790
|
CrcCalculator.crc32 = function(buf) {
|
|
754
791
|
let crc = -1;
|
|
755
|
-
for (let
|
|
756
|
-
crc = crcTable[(crc ^ buf[
|
|
792
|
+
for (let i3 = 0; i3 < buf.length; i3++) {
|
|
793
|
+
crc = crcTable[(crc ^ buf[i3]) & 255] ^ crc >>> 8;
|
|
757
794
|
}
|
|
758
795
|
return crc ^ -1;
|
|
759
796
|
};
|
|
@@ -799,8 +836,8 @@ var require_parser = __commonJS({
|
|
|
799
836
|
};
|
|
800
837
|
Parser.prototype._parseSignature = function(data) {
|
|
801
838
|
let signature = constants.PNG_SIGNATURE;
|
|
802
|
-
for (let
|
|
803
|
-
if (data[
|
|
839
|
+
for (let i3 = 0; i3 < signature.length; i3++) {
|
|
840
|
+
if (data[i3] !== signature[i3]) {
|
|
804
841
|
this.error(new Error("Invalid file signature"));
|
|
805
842
|
return;
|
|
806
843
|
}
|
|
@@ -811,8 +848,8 @@ var require_parser = __commonJS({
|
|
|
811
848
|
let length = data.readUInt32BE(0);
|
|
812
849
|
let type = data.readUInt32BE(4);
|
|
813
850
|
let name = "";
|
|
814
|
-
for (let
|
|
815
|
-
name += String.fromCharCode(data[
|
|
851
|
+
for (let i3 = 4; i3 < 8; i3++) {
|
|
852
|
+
name += String.fromCharCode(data[i3]);
|
|
816
853
|
}
|
|
817
854
|
let ancillary = Boolean(data[4] & 32);
|
|
818
855
|
if (!this._hasIHDR && type !== constants.TYPE_IHDR) {
|
|
@@ -901,8 +938,8 @@ var require_parser = __commonJS({
|
|
|
901
938
|
Parser.prototype._parsePLTE = function(data) {
|
|
902
939
|
this._crc.write(data);
|
|
903
940
|
let entries = Math.floor(data.length / 3);
|
|
904
|
-
for (let
|
|
905
|
-
this._palette.push([data[
|
|
941
|
+
for (let i3 = 0; i3 < entries; i3++) {
|
|
942
|
+
this._palette.push([data[i3 * 3], data[i3 * 3 + 1], data[i3 * 3 + 2], 255]);
|
|
906
943
|
}
|
|
907
944
|
this.palette(this._palette);
|
|
908
945
|
this._handleChunkEnd();
|
|
@@ -922,8 +959,8 @@ var require_parser = __commonJS({
|
|
|
922
959
|
this.error(new Error("More transparent colors than palette size"));
|
|
923
960
|
return;
|
|
924
961
|
}
|
|
925
|
-
for (let
|
|
926
|
-
this._palette[
|
|
962
|
+
for (let i3 = 0; i3 < data.length; i3++) {
|
|
963
|
+
this._palette[i3][3] = data[i3];
|
|
927
964
|
}
|
|
928
965
|
this.palette(this._palette);
|
|
929
966
|
}
|
|
@@ -1078,20 +1115,20 @@ var require_bitmapper = __commonJS({
|
|
|
1078
1115
|
];
|
|
1079
1116
|
function bitRetriever(data, depth) {
|
|
1080
1117
|
let leftOver = [];
|
|
1081
|
-
let
|
|
1118
|
+
let i3 = 0;
|
|
1082
1119
|
function split() {
|
|
1083
|
-
if (
|
|
1120
|
+
if (i3 === data.length) {
|
|
1084
1121
|
throw new Error("Ran out of data");
|
|
1085
1122
|
}
|
|
1086
|
-
let byte = data[
|
|
1087
|
-
|
|
1123
|
+
let byte = data[i3];
|
|
1124
|
+
i3++;
|
|
1088
1125
|
let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1;
|
|
1089
1126
|
switch (depth) {
|
|
1090
1127
|
default:
|
|
1091
1128
|
throw new Error("unrecognised depth");
|
|
1092
1129
|
case 16:
|
|
1093
|
-
byte2 = data[
|
|
1094
|
-
|
|
1130
|
+
byte2 = data[i3];
|
|
1131
|
+
i3++;
|
|
1095
1132
|
leftOver.push((byte << 8) + byte2);
|
|
1096
1133
|
break;
|
|
1097
1134
|
case 4:
|
|
@@ -1132,7 +1169,7 @@ var require_bitmapper = __commonJS({
|
|
|
1132
1169
|
leftOver.length = 0;
|
|
1133
1170
|
},
|
|
1134
1171
|
end: function() {
|
|
1135
|
-
if (
|
|
1172
|
+
if (i3 !== data.length) {
|
|
1136
1173
|
throw new Error("extra data found");
|
|
1137
1174
|
}
|
|
1138
1175
|
}
|
|
@@ -1241,8 +1278,8 @@ var require_format_normaliser = __commonJS({
|
|
|
1241
1278
|
if (!color) {
|
|
1242
1279
|
throw new Error("index " + indata[pxPos] + " not in palette");
|
|
1243
1280
|
}
|
|
1244
|
-
for (let
|
|
1245
|
-
outdata[pxPos +
|
|
1281
|
+
for (let i3 = 0; i3 < 4; i3++) {
|
|
1282
|
+
outdata[pxPos + i3] = color[i3];
|
|
1246
1283
|
}
|
|
1247
1284
|
pxPos += 4;
|
|
1248
1285
|
}
|
|
@@ -1261,8 +1298,8 @@ var require_format_normaliser = __commonJS({
|
|
|
1261
1298
|
makeTrans = true;
|
|
1262
1299
|
}
|
|
1263
1300
|
if (makeTrans) {
|
|
1264
|
-
for (let
|
|
1265
|
-
outdata[pxPos +
|
|
1301
|
+
for (let i3 = 0; i3 < 4; i3++) {
|
|
1302
|
+
outdata[pxPos + i3] = 0;
|
|
1266
1303
|
}
|
|
1267
1304
|
}
|
|
1268
1305
|
pxPos += 4;
|
|
@@ -1275,9 +1312,9 @@ var require_format_normaliser = __commonJS({
|
|
|
1275
1312
|
let pxPos = 0;
|
|
1276
1313
|
for (let y = 0; y < height; y++) {
|
|
1277
1314
|
for (let x = 0; x < width; x++) {
|
|
1278
|
-
for (let
|
|
1279
|
-
outdata[pxPos +
|
|
1280
|
-
indata[pxPos +
|
|
1315
|
+
for (let i3 = 0; i3 < 4; i3++) {
|
|
1316
|
+
outdata[pxPos + i3] = Math.floor(
|
|
1317
|
+
indata[pxPos + i3] * maxOutSample / maxInSample + 0.5
|
|
1281
1318
|
);
|
|
1282
1319
|
}
|
|
1283
1320
|
pxPos += 4;
|
|
@@ -1603,8 +1640,8 @@ var require_filter_pack = __commonJS({
|
|
|
1603
1640
|
function filterSumNone(pxData, pxPos, byteWidth) {
|
|
1604
1641
|
let sum = 0;
|
|
1605
1642
|
let length = pxPos + byteWidth;
|
|
1606
|
-
for (let
|
|
1607
|
-
sum += Math.abs(pxData[
|
|
1643
|
+
for (let i3 = pxPos; i3 < length; i3++) {
|
|
1644
|
+
sum += Math.abs(pxData[i3]);
|
|
1608
1645
|
}
|
|
1609
1646
|
return sum;
|
|
1610
1647
|
}
|
|
@@ -1713,10 +1750,10 @@ var require_filter_pack = __commonJS({
|
|
|
1713
1750
|
for (let y = 0; y < height; y++) {
|
|
1714
1751
|
if (filterTypes.length > 1) {
|
|
1715
1752
|
let min = Infinity;
|
|
1716
|
-
for (let
|
|
1717
|
-
let sum = filterSums[filterTypes[
|
|
1753
|
+
for (let i3 = 0; i3 < filterTypes.length; i3++) {
|
|
1754
|
+
let sum = filterSums[filterTypes[i3]](pxData, pxPos, byteWidth, bpp);
|
|
1718
1755
|
if (sum < min) {
|
|
1719
|
-
sel = filterTypes[
|
|
1756
|
+
sel = filterTypes[i3];
|
|
1720
1757
|
min = sum;
|
|
1721
1758
|
}
|
|
1722
1759
|
}
|
|
@@ -1913,7 +1950,7 @@ var require_sync_inflate = __commonJS({
|
|
|
1913
1950
|
if (typeof asyncCb === "function") {
|
|
1914
1951
|
return zlib.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb);
|
|
1915
1952
|
}
|
|
1916
|
-
let
|
|
1953
|
+
let self2 = this;
|
|
1917
1954
|
let availInBefore = chunk && chunk.length;
|
|
1918
1955
|
let availOutBefore = this._chunkSize - this._offset;
|
|
1919
1956
|
let leftToInflate = this._maxLength;
|
|
@@ -1925,14 +1962,14 @@ var require_sync_inflate = __commonJS({
|
|
|
1925
1962
|
error = err;
|
|
1926
1963
|
});
|
|
1927
1964
|
function handleChunk(availInAfter, availOutAfter) {
|
|
1928
|
-
if (
|
|
1965
|
+
if (self2._hadError) {
|
|
1929
1966
|
return;
|
|
1930
1967
|
}
|
|
1931
1968
|
let have = availOutBefore - availOutAfter;
|
|
1932
1969
|
assert(have >= 0, "have should not go down");
|
|
1933
1970
|
if (have > 0) {
|
|
1934
|
-
let out =
|
|
1935
|
-
|
|
1971
|
+
let out = self2._buffer.slice(self2._offset, self2._offset + have);
|
|
1972
|
+
self2._offset += have;
|
|
1936
1973
|
if (out.length > leftToInflate) {
|
|
1937
1974
|
out = out.slice(0, leftToInflate);
|
|
1938
1975
|
}
|
|
@@ -1943,10 +1980,10 @@ var require_sync_inflate = __commonJS({
|
|
|
1943
1980
|
return false;
|
|
1944
1981
|
}
|
|
1945
1982
|
}
|
|
1946
|
-
if (availOutAfter === 0 ||
|
|
1947
|
-
availOutBefore =
|
|
1948
|
-
|
|
1949
|
-
|
|
1983
|
+
if (availOutAfter === 0 || self2._offset >= self2._chunkSize) {
|
|
1984
|
+
availOutBefore = self2._chunkSize;
|
|
1985
|
+
self2._offset = 0;
|
|
1986
|
+
self2._buffer = Buffer.allocUnsafe(self2._chunkSize);
|
|
1950
1987
|
}
|
|
1951
1988
|
if (availOutAfter === 0) {
|
|
1952
1989
|
inOff += availInBefore - availInAfter;
|
|
@@ -2349,10 +2386,10 @@ var require_png = __commonJS({
|
|
|
2349
2386
|
for (let y = 0; y < src.height; y++) {
|
|
2350
2387
|
for (let x = 0; x < src.width; x++) {
|
|
2351
2388
|
let idx = src.width * y + x << 2;
|
|
2352
|
-
for (let
|
|
2353
|
-
let sample = src.data[idx +
|
|
2389
|
+
for (let i3 = 0; i3 < 3; i3++) {
|
|
2390
|
+
let sample = src.data[idx + i3] / 255;
|
|
2354
2391
|
sample = Math.pow(sample, 1 / 2.2 / src.gamma);
|
|
2355
|
-
src.data[idx +
|
|
2392
|
+
src.data[idx + i3] = Math.round(sample * 255);
|
|
2356
2393
|
}
|
|
2357
2394
|
}
|
|
2358
2395
|
}
|
|
@@ -2368,37 +2405,37 @@ var require_png = __commonJS({
|
|
|
2368
2405
|
// ../codec-pngjs/dist/index.mjs
|
|
2369
2406
|
var dist_exports = {};
|
|
2370
2407
|
__export(dist_exports, {
|
|
2371
|
-
|
|
2372
|
-
|
|
2408
|
+
codecPngjs: () => h,
|
|
2409
|
+
default: () => m
|
|
2373
2410
|
});
|
|
2374
2411
|
async function d(r) {
|
|
2375
|
-
return new Promise((
|
|
2412
|
+
return new Promise((i3, n3) => {
|
|
2376
2413
|
try {
|
|
2377
2414
|
let t = typeof r == "string" ? (0, import_fs.readFileSync)(r) : r, e = import_pngjs.PNG.sync.read(t);
|
|
2378
|
-
|
|
2415
|
+
i3({ data: e.data, width: e.width, height: e.height });
|
|
2379
2416
|
} catch (t) {
|
|
2380
|
-
|
|
2417
|
+
n3(new Error(`Failed to read PNG file ${r}: ${t}`));
|
|
2381
2418
|
}
|
|
2382
2419
|
});
|
|
2383
2420
|
}
|
|
2384
|
-
async function
|
|
2385
|
-
return new Promise((
|
|
2421
|
+
async function c(r, i3) {
|
|
2422
|
+
return new Promise((n3, t) => {
|
|
2386
2423
|
try {
|
|
2387
2424
|
let e = new import_pngjs.PNG({ width: r.width, height: r.height });
|
|
2388
|
-
e.data = Buffer.isBuffer(r.data) ? r.data : Buffer.from(r.data.buffer), (0, import_fs.writeFileSync)(
|
|
2425
|
+
e.data = Buffer.isBuffer(r.data) ? r.data : Buffer.from(r.data.buffer), (0, import_fs.writeFileSync)(i3, import_pngjs.PNG.sync.write(e)), n3();
|
|
2389
2426
|
} catch (e) {
|
|
2390
|
-
t(new Error(`Failed to write PNG file ${
|
|
2427
|
+
t(new Error(`Failed to write PNG file ${i3}: ${e}`));
|
|
2391
2428
|
}
|
|
2392
2429
|
});
|
|
2393
2430
|
}
|
|
2394
|
-
var import_fs, import_pngjs,
|
|
2431
|
+
var import_fs, import_pngjs, h, m;
|
|
2395
2432
|
var init_dist2 = __esm({
|
|
2396
2433
|
"../codec-pngjs/dist/index.mjs"() {
|
|
2397
2434
|
"use strict";
|
|
2398
2435
|
import_fs = require("fs");
|
|
2399
2436
|
import_pngjs = __toESM(require_png(), 1);
|
|
2400
|
-
|
|
2401
|
-
m =
|
|
2437
|
+
h = { read: d, write: c };
|
|
2438
|
+
m = h;
|
|
2402
2439
|
}
|
|
2403
2440
|
});
|
|
2404
2441
|
|
|
@@ -2493,7 +2530,7 @@ var require_filesystem = __commonJS({
|
|
|
2493
2530
|
var LDD_PATH = "/usr/bin/ldd";
|
|
2494
2531
|
var SELF_PATH = "/proc/self/exe";
|
|
2495
2532
|
var MAX_LENGTH = 2048;
|
|
2496
|
-
var
|
|
2533
|
+
var readFileSync3 = (path) => {
|
|
2497
2534
|
const fd = fs.openSync(path, "r");
|
|
2498
2535
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2499
2536
|
const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
@@ -2518,7 +2555,7 @@ var require_filesystem = __commonJS({
|
|
|
2518
2555
|
module2.exports = {
|
|
2519
2556
|
LDD_PATH,
|
|
2520
2557
|
SELF_PATH,
|
|
2521
|
-
readFileSync:
|
|
2558
|
+
readFileSync: readFileSync3,
|
|
2522
2559
|
readFile
|
|
2523
2560
|
};
|
|
2524
2561
|
}
|
|
@@ -2544,8 +2581,8 @@ var require_elf = __commonJS({
|
|
|
2544
2581
|
const offset = elf.readUInt32LE(32);
|
|
2545
2582
|
const size = elf.readUInt16LE(54);
|
|
2546
2583
|
const count = elf.readUInt16LE(56);
|
|
2547
|
-
for (let
|
|
2548
|
-
const headerOffset = offset +
|
|
2584
|
+
for (let i3 = 0; i3 < count; i3++) {
|
|
2585
|
+
const headerOffset = offset + i3 * size;
|
|
2549
2586
|
const type = elf.readUInt32LE(headerOffset);
|
|
2550
2587
|
if (type === 3) {
|
|
2551
2588
|
const fileOffset = elf.readUInt32LE(headerOffset + 8);
|
|
@@ -2567,7 +2604,7 @@ var require_detect_libc = __commonJS({
|
|
|
2567
2604
|
"use strict";
|
|
2568
2605
|
var childProcess = require("child_process");
|
|
2569
2606
|
var { isLinux, getReport } = require_process();
|
|
2570
|
-
var { LDD_PATH, SELF_PATH, readFile, readFileSync:
|
|
2607
|
+
var { LDD_PATH, SELF_PATH, readFile, readFileSync: readFileSync3 } = require_filesystem();
|
|
2571
2608
|
var { interpreterPath } = require_elf();
|
|
2572
2609
|
var cachedFamilyInterpreter;
|
|
2573
2610
|
var cachedFamilyFilesystem;
|
|
@@ -2659,7 +2696,7 @@ var require_detect_libc = __commonJS({
|
|
|
2659
2696
|
}
|
|
2660
2697
|
cachedFamilyFilesystem = null;
|
|
2661
2698
|
try {
|
|
2662
|
-
const lddContent =
|
|
2699
|
+
const lddContent = readFileSync3(LDD_PATH);
|
|
2663
2700
|
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
|
2664
2701
|
} catch (e) {
|
|
2665
2702
|
}
|
|
@@ -2684,7 +2721,7 @@ var require_detect_libc = __commonJS({
|
|
|
2684
2721
|
}
|
|
2685
2722
|
cachedFamilyInterpreter = null;
|
|
2686
2723
|
try {
|
|
2687
|
-
const selfContent =
|
|
2724
|
+
const selfContent = readFileSync3(SELF_PATH);
|
|
2688
2725
|
const path = interpreterPath(selfContent);
|
|
2689
2726
|
cachedFamilyInterpreter = familyFromInterpreterPath(path);
|
|
2690
2727
|
} catch (e) {
|
|
@@ -2748,7 +2785,7 @@ var require_detect_libc = __commonJS({
|
|
|
2748
2785
|
}
|
|
2749
2786
|
cachedVersionFilesystem = null;
|
|
2750
2787
|
try {
|
|
2751
|
-
const lddContent =
|
|
2788
|
+
const lddContent = readFileSync3(LDD_PATH);
|
|
2752
2789
|
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
|
2753
2790
|
if (versionMatch) {
|
|
2754
2791
|
cachedVersionFilesystem = versionMatch[1];
|
|
@@ -2764,7 +2801,7 @@ var require_detect_libc = __commonJS({
|
|
|
2764
2801
|
}
|
|
2765
2802
|
return null;
|
|
2766
2803
|
};
|
|
2767
|
-
var versionSuffix = (
|
|
2804
|
+
var versionSuffix = (s) => s.trim().split(/\s+/)[1];
|
|
2768
2805
|
var versionFromCommand = (out) => {
|
|
2769
2806
|
const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
|
|
2770
2807
|
if (getconf && getconf.includes(GLIBC)) {
|
|
@@ -3020,14 +3057,14 @@ var require_semver = __commonJS({
|
|
|
3020
3057
|
this.options = options;
|
|
3021
3058
|
this.loose = !!options.loose;
|
|
3022
3059
|
this.includePrerelease = !!options.includePrerelease;
|
|
3023
|
-
const
|
|
3024
|
-
if (!
|
|
3060
|
+
const m3 = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
3061
|
+
if (!m3) {
|
|
3025
3062
|
throw new TypeError(`Invalid Version: ${version}`);
|
|
3026
3063
|
}
|
|
3027
3064
|
this.raw = version;
|
|
3028
|
-
this.major = +
|
|
3029
|
-
this.minor = +
|
|
3030
|
-
this.patch = +
|
|
3065
|
+
this.major = +m3[1];
|
|
3066
|
+
this.minor = +m3[2];
|
|
3067
|
+
this.patch = +m3[3];
|
|
3031
3068
|
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
3032
3069
|
throw new TypeError("Invalid major version");
|
|
3033
3070
|
}
|
|
@@ -3037,10 +3074,10 @@ var require_semver = __commonJS({
|
|
|
3037
3074
|
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
3038
3075
|
throw new TypeError("Invalid patch version");
|
|
3039
3076
|
}
|
|
3040
|
-
if (!
|
|
3077
|
+
if (!m3[4]) {
|
|
3041
3078
|
this.prerelease = [];
|
|
3042
3079
|
} else {
|
|
3043
|
-
this.prerelease =
|
|
3080
|
+
this.prerelease = m3[4].split(".").map((id) => {
|
|
3044
3081
|
if (/^[0-9]+$/.test(id)) {
|
|
3045
3082
|
const num = +id;
|
|
3046
3083
|
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
@@ -3050,7 +3087,7 @@ var require_semver = __commonJS({
|
|
|
3050
3087
|
return id;
|
|
3051
3088
|
});
|
|
3052
3089
|
}
|
|
3053
|
-
this.build =
|
|
3090
|
+
this.build = m3[5] ? m3[5].split(".") : [];
|
|
3054
3091
|
this.format();
|
|
3055
3092
|
}
|
|
3056
3093
|
format() {
|
|
@@ -3111,11 +3148,11 @@ var require_semver = __commonJS({
|
|
|
3111
3148
|
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
3112
3149
|
return 0;
|
|
3113
3150
|
}
|
|
3114
|
-
let
|
|
3151
|
+
let i3 = 0;
|
|
3115
3152
|
do {
|
|
3116
|
-
const a2 = this.prerelease[
|
|
3117
|
-
const b = other.prerelease[
|
|
3118
|
-
debug("prerelease compare",
|
|
3153
|
+
const a2 = this.prerelease[i3];
|
|
3154
|
+
const b = other.prerelease[i3];
|
|
3155
|
+
debug("prerelease compare", i3, a2, b);
|
|
3119
3156
|
if (a2 === void 0 && b === void 0) {
|
|
3120
3157
|
return 0;
|
|
3121
3158
|
} else if (b === void 0) {
|
|
@@ -3127,17 +3164,17 @@ var require_semver = __commonJS({
|
|
|
3127
3164
|
} else {
|
|
3128
3165
|
return compareIdentifiers(a2, b);
|
|
3129
3166
|
}
|
|
3130
|
-
} while (++
|
|
3167
|
+
} while (++i3);
|
|
3131
3168
|
}
|
|
3132
3169
|
compareBuild(other) {
|
|
3133
3170
|
if (!(other instanceof _SemVer)) {
|
|
3134
3171
|
other = new _SemVer(other, this.options);
|
|
3135
3172
|
}
|
|
3136
|
-
let
|
|
3173
|
+
let i3 = 0;
|
|
3137
3174
|
do {
|
|
3138
|
-
const a2 = this.build[
|
|
3139
|
-
const b = other.build[
|
|
3140
|
-
debug("build compare",
|
|
3175
|
+
const a2 = this.build[i3];
|
|
3176
|
+
const b = other.build[i3];
|
|
3177
|
+
debug("build compare", i3, a2, b);
|
|
3141
3178
|
if (a2 === void 0 && b === void 0) {
|
|
3142
3179
|
return 0;
|
|
3143
3180
|
} else if (b === void 0) {
|
|
@@ -3149,7 +3186,7 @@ var require_semver = __commonJS({
|
|
|
3149
3186
|
} else {
|
|
3150
3187
|
return compareIdentifiers(a2, b);
|
|
3151
3188
|
}
|
|
3152
|
-
} while (++
|
|
3189
|
+
} while (++i3);
|
|
3153
3190
|
}
|
|
3154
3191
|
// preminor will bump the version up to the next minor release, and immediately
|
|
3155
3192
|
// down to pre-release. premajor and prepatch work the same way.
|
|
@@ -3226,14 +3263,14 @@ var require_semver = __commonJS({
|
|
|
3226
3263
|
if (this.prerelease.length === 0) {
|
|
3227
3264
|
this.prerelease = [base];
|
|
3228
3265
|
} else {
|
|
3229
|
-
let
|
|
3230
|
-
while (--
|
|
3231
|
-
if (typeof this.prerelease[
|
|
3232
|
-
this.prerelease[
|
|
3233
|
-
|
|
3266
|
+
let i3 = this.prerelease.length;
|
|
3267
|
+
while (--i3 >= 0) {
|
|
3268
|
+
if (typeof this.prerelease[i3] === "number") {
|
|
3269
|
+
this.prerelease[i3]++;
|
|
3270
|
+
i3 = -2;
|
|
3234
3271
|
}
|
|
3235
3272
|
}
|
|
3236
|
-
if (
|
|
3273
|
+
if (i3 === -1) {
|
|
3237
3274
|
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
3238
3275
|
throw new Error("invalid increment argument: identifier already exists");
|
|
3239
3276
|
}
|
|
@@ -3527,18 +3564,18 @@ var require_comparator = __commonJS({
|
|
|
3527
3564
|
}
|
|
3528
3565
|
parse(comp) {
|
|
3529
3566
|
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
3530
|
-
const
|
|
3531
|
-
if (!
|
|
3567
|
+
const m3 = comp.match(r);
|
|
3568
|
+
if (!m3) {
|
|
3532
3569
|
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
3533
3570
|
}
|
|
3534
|
-
this.operator =
|
|
3571
|
+
this.operator = m3[1] !== void 0 ? m3[1] : "";
|
|
3535
3572
|
if (this.operator === "=") {
|
|
3536
3573
|
this.operator = "";
|
|
3537
3574
|
}
|
|
3538
|
-
if (!
|
|
3575
|
+
if (!m3[2]) {
|
|
3539
3576
|
this.semver = ANY;
|
|
3540
3577
|
} else {
|
|
3541
|
-
this.semver = new SemVer(
|
|
3578
|
+
this.semver = new SemVer(m3[2], this.options.loose);
|
|
3542
3579
|
}
|
|
3543
3580
|
}
|
|
3544
3581
|
toString() {
|
|
@@ -3633,19 +3670,19 @@ var require_range = __commonJS({
|
|
|
3633
3670
|
this.loose = !!options.loose;
|
|
3634
3671
|
this.includePrerelease = !!options.includePrerelease;
|
|
3635
3672
|
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
3636
|
-
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((
|
|
3673
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c3) => c3.length);
|
|
3637
3674
|
if (!this.set.length) {
|
|
3638
3675
|
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
3639
3676
|
}
|
|
3640
3677
|
if (this.set.length > 1) {
|
|
3641
3678
|
const first = this.set[0];
|
|
3642
|
-
this.set = this.set.filter((
|
|
3679
|
+
this.set = this.set.filter((c3) => !isNullSet(c3[0]));
|
|
3643
3680
|
if (this.set.length === 0) {
|
|
3644
3681
|
this.set = [first];
|
|
3645
3682
|
} else if (this.set.length > 1) {
|
|
3646
|
-
for (const
|
|
3647
|
-
if (
|
|
3648
|
-
this.set = [
|
|
3683
|
+
for (const c3 of this.set) {
|
|
3684
|
+
if (c3.length === 1 && isAny(c3[0])) {
|
|
3685
|
+
this.set = [c3];
|
|
3649
3686
|
break;
|
|
3650
3687
|
}
|
|
3651
3688
|
}
|
|
@@ -3656,11 +3693,11 @@ var require_range = __commonJS({
|
|
|
3656
3693
|
get range() {
|
|
3657
3694
|
if (this.formatted === void 0) {
|
|
3658
3695
|
this.formatted = "";
|
|
3659
|
-
for (let
|
|
3660
|
-
if (
|
|
3696
|
+
for (let i3 = 0; i3 < this.set.length; i3++) {
|
|
3697
|
+
if (i3 > 0) {
|
|
3661
3698
|
this.formatted += "||";
|
|
3662
3699
|
}
|
|
3663
|
-
const comps = this.set[
|
|
3700
|
+
const comps = this.set[i3];
|
|
3664
3701
|
for (let k = 0; k < comps.length; k++) {
|
|
3665
3702
|
if (k > 0) {
|
|
3666
3703
|
this.formatted += " ";
|
|
@@ -3743,8 +3780,8 @@ var require_range = __commonJS({
|
|
|
3743
3780
|
return false;
|
|
3744
3781
|
}
|
|
3745
3782
|
}
|
|
3746
|
-
for (let
|
|
3747
|
-
if (testSet(this.set[
|
|
3783
|
+
for (let i3 = 0; i3 < this.set.length; i3++) {
|
|
3784
|
+
if (testSet(this.set[i3], version, this.options)) {
|
|
3748
3785
|
return true;
|
|
3749
3786
|
}
|
|
3750
3787
|
}
|
|
@@ -3766,8 +3803,8 @@ var require_range = __commonJS({
|
|
|
3766
3803
|
caretTrimReplace
|
|
3767
3804
|
} = require_re();
|
|
3768
3805
|
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants2();
|
|
3769
|
-
var isNullSet = (
|
|
3770
|
-
var isAny = (
|
|
3806
|
+
var isNullSet = (c3) => c3.value === "<0.0.0-0";
|
|
3807
|
+
var isAny = (c3) => c3.value === "";
|
|
3771
3808
|
var isSatisfiable = (comparators, options) => {
|
|
3772
3809
|
let result = true;
|
|
3773
3810
|
const remainingComparators = comparators.slice();
|
|
@@ -3795,70 +3832,70 @@ var require_range = __commonJS({
|
|
|
3795
3832
|
};
|
|
3796
3833
|
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
3797
3834
|
var replaceTildes = (comp, options) => {
|
|
3798
|
-
return comp.trim().split(/\s+/).map((
|
|
3835
|
+
return comp.trim().split(/\s+/).map((c3) => replaceTilde(c3, options)).join(" ");
|
|
3799
3836
|
};
|
|
3800
3837
|
var replaceTilde = (comp, options) => {
|
|
3801
3838
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
3802
|
-
return comp.replace(r, (_2, M,
|
|
3803
|
-
debug("tilde", comp, _2, M,
|
|
3839
|
+
return comp.replace(r, (_2, M, m3, p3, pr) => {
|
|
3840
|
+
debug("tilde", comp, _2, M, m3, p3, pr);
|
|
3804
3841
|
let ret;
|
|
3805
3842
|
if (isX(M)) {
|
|
3806
3843
|
ret = "";
|
|
3807
|
-
} else if (isX(
|
|
3844
|
+
} else if (isX(m3)) {
|
|
3808
3845
|
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
3809
|
-
} else if (isX(
|
|
3810
|
-
ret = `>=${M}.${
|
|
3846
|
+
} else if (isX(p3)) {
|
|
3847
|
+
ret = `>=${M}.${m3}.0 <${M}.${+m3 + 1}.0-0`;
|
|
3811
3848
|
} else if (pr) {
|
|
3812
3849
|
debug("replaceTilde pr", pr);
|
|
3813
|
-
ret = `>=${M}.${
|
|
3850
|
+
ret = `>=${M}.${m3}.${p3}-${pr} <${M}.${+m3 + 1}.0-0`;
|
|
3814
3851
|
} else {
|
|
3815
|
-
ret = `>=${M}.${
|
|
3852
|
+
ret = `>=${M}.${m3}.${p3} <${M}.${+m3 + 1}.0-0`;
|
|
3816
3853
|
}
|
|
3817
3854
|
debug("tilde return", ret);
|
|
3818
3855
|
return ret;
|
|
3819
3856
|
});
|
|
3820
3857
|
};
|
|
3821
3858
|
var replaceCarets = (comp, options) => {
|
|
3822
|
-
return comp.trim().split(/\s+/).map((
|
|
3859
|
+
return comp.trim().split(/\s+/).map((c3) => replaceCaret(c3, options)).join(" ");
|
|
3823
3860
|
};
|
|
3824
3861
|
var replaceCaret = (comp, options) => {
|
|
3825
3862
|
debug("caret", comp, options);
|
|
3826
3863
|
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
3827
3864
|
const z2 = options.includePrerelease ? "-0" : "";
|
|
3828
|
-
return comp.replace(r, (_2, M,
|
|
3829
|
-
debug("caret", comp, _2, M,
|
|
3865
|
+
return comp.replace(r, (_2, M, m3, p3, pr) => {
|
|
3866
|
+
debug("caret", comp, _2, M, m3, p3, pr);
|
|
3830
3867
|
let ret;
|
|
3831
3868
|
if (isX(M)) {
|
|
3832
3869
|
ret = "";
|
|
3833
|
-
} else if (isX(
|
|
3870
|
+
} else if (isX(m3)) {
|
|
3834
3871
|
ret = `>=${M}.0.0${z2} <${+M + 1}.0.0-0`;
|
|
3835
|
-
} else if (isX(
|
|
3872
|
+
} else if (isX(p3)) {
|
|
3836
3873
|
if (M === "0") {
|
|
3837
|
-
ret = `>=${M}.${
|
|
3874
|
+
ret = `>=${M}.${m3}.0${z2} <${M}.${+m3 + 1}.0-0`;
|
|
3838
3875
|
} else {
|
|
3839
|
-
ret = `>=${M}.${
|
|
3876
|
+
ret = `>=${M}.${m3}.0${z2} <${+M + 1}.0.0-0`;
|
|
3840
3877
|
}
|
|
3841
3878
|
} else if (pr) {
|
|
3842
3879
|
debug("replaceCaret pr", pr);
|
|
3843
3880
|
if (M === "0") {
|
|
3844
|
-
if (
|
|
3845
|
-
ret = `>=${M}.${
|
|
3881
|
+
if (m3 === "0") {
|
|
3882
|
+
ret = `>=${M}.${m3}.${p3}-${pr} <${M}.${m3}.${+p3 + 1}-0`;
|
|
3846
3883
|
} else {
|
|
3847
|
-
ret = `>=${M}.${
|
|
3884
|
+
ret = `>=${M}.${m3}.${p3}-${pr} <${M}.${+m3 + 1}.0-0`;
|
|
3848
3885
|
}
|
|
3849
3886
|
} else {
|
|
3850
|
-
ret = `>=${M}.${
|
|
3887
|
+
ret = `>=${M}.${m3}.${p3}-${pr} <${+M + 1}.0.0-0`;
|
|
3851
3888
|
}
|
|
3852
3889
|
} else {
|
|
3853
3890
|
debug("no pr");
|
|
3854
3891
|
if (M === "0") {
|
|
3855
|
-
if (
|
|
3856
|
-
ret = `>=${M}.${
|
|
3892
|
+
if (m3 === "0") {
|
|
3893
|
+
ret = `>=${M}.${m3}.${p3}${z2} <${M}.${m3}.${+p3 + 1}-0`;
|
|
3857
3894
|
} else {
|
|
3858
|
-
ret = `>=${M}.${
|
|
3895
|
+
ret = `>=${M}.${m3}.${p3}${z2} <${M}.${+m3 + 1}.0-0`;
|
|
3859
3896
|
}
|
|
3860
3897
|
} else {
|
|
3861
|
-
ret = `>=${M}.${
|
|
3898
|
+
ret = `>=${M}.${m3}.${p3} <${+M + 1}.0.0-0`;
|
|
3862
3899
|
}
|
|
3863
3900
|
}
|
|
3864
3901
|
debug("caret return", ret);
|
|
@@ -3867,16 +3904,16 @@ var require_range = __commonJS({
|
|
|
3867
3904
|
};
|
|
3868
3905
|
var replaceXRanges = (comp, options) => {
|
|
3869
3906
|
debug("replaceXRanges", comp, options);
|
|
3870
|
-
return comp.split(/\s+/).map((
|
|
3907
|
+
return comp.split(/\s+/).map((c3) => replaceXRange(c3, options)).join(" ");
|
|
3871
3908
|
};
|
|
3872
3909
|
var replaceXRange = (comp, options) => {
|
|
3873
3910
|
comp = comp.trim();
|
|
3874
3911
|
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
3875
|
-
return comp.replace(r, (ret, gtlt, M,
|
|
3876
|
-
debug("xRange", comp, ret, gtlt, M,
|
|
3912
|
+
return comp.replace(r, (ret, gtlt, M, m3, p3, pr) => {
|
|
3913
|
+
debug("xRange", comp, ret, gtlt, M, m3, p3, pr);
|
|
3877
3914
|
const xM = isX(M);
|
|
3878
|
-
const xm = xM || isX(
|
|
3879
|
-
const xp = xm || isX(
|
|
3915
|
+
const xm = xM || isX(m3);
|
|
3916
|
+
const xp = xm || isX(p3);
|
|
3880
3917
|
const anyX = xp;
|
|
3881
3918
|
if (gtlt === "=" && anyX) {
|
|
3882
3919
|
gtlt = "";
|
|
@@ -3890,35 +3927,35 @@ var require_range = __commonJS({
|
|
|
3890
3927
|
}
|
|
3891
3928
|
} else if (gtlt && anyX) {
|
|
3892
3929
|
if (xm) {
|
|
3893
|
-
|
|
3930
|
+
m3 = 0;
|
|
3894
3931
|
}
|
|
3895
|
-
|
|
3932
|
+
p3 = 0;
|
|
3896
3933
|
if (gtlt === ">") {
|
|
3897
3934
|
gtlt = ">=";
|
|
3898
3935
|
if (xm) {
|
|
3899
3936
|
M = +M + 1;
|
|
3900
|
-
|
|
3901
|
-
|
|
3937
|
+
m3 = 0;
|
|
3938
|
+
p3 = 0;
|
|
3902
3939
|
} else {
|
|
3903
|
-
|
|
3904
|
-
|
|
3940
|
+
m3 = +m3 + 1;
|
|
3941
|
+
p3 = 0;
|
|
3905
3942
|
}
|
|
3906
3943
|
} else if (gtlt === "<=") {
|
|
3907
3944
|
gtlt = "<";
|
|
3908
3945
|
if (xm) {
|
|
3909
3946
|
M = +M + 1;
|
|
3910
3947
|
} else {
|
|
3911
|
-
|
|
3948
|
+
m3 = +m3 + 1;
|
|
3912
3949
|
}
|
|
3913
3950
|
}
|
|
3914
3951
|
if (gtlt === "<") {
|
|
3915
3952
|
pr = "-0";
|
|
3916
3953
|
}
|
|
3917
|
-
ret = `${gtlt + M}.${
|
|
3954
|
+
ret = `${gtlt + M}.${m3}.${p3}${pr}`;
|
|
3918
3955
|
} else if (xm) {
|
|
3919
3956
|
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
3920
3957
|
} else if (xp) {
|
|
3921
|
-
ret = `>=${M}.${
|
|
3958
|
+
ret = `>=${M}.${m3}.0${pr} <${M}.${+m3 + 1}.0-0`;
|
|
3922
3959
|
}
|
|
3923
3960
|
debug("xRange return", ret);
|
|
3924
3961
|
return ret;
|
|
@@ -3960,19 +3997,19 @@ var require_range = __commonJS({
|
|
|
3960
3997
|
return `${from} ${to}`.trim();
|
|
3961
3998
|
};
|
|
3962
3999
|
var testSet = (set, version, options) => {
|
|
3963
|
-
for (let
|
|
3964
|
-
if (!set[
|
|
4000
|
+
for (let i3 = 0; i3 < set.length; i3++) {
|
|
4001
|
+
if (!set[i3].test(version)) {
|
|
3965
4002
|
return false;
|
|
3966
4003
|
}
|
|
3967
4004
|
}
|
|
3968
4005
|
if (version.prerelease.length && !options.includePrerelease) {
|
|
3969
|
-
for (let
|
|
3970
|
-
debug(set[
|
|
3971
|
-
if (set[
|
|
4006
|
+
for (let i3 = 0; i3 < set.length; i3++) {
|
|
4007
|
+
debug(set[i3].semver);
|
|
4008
|
+
if (set[i3].semver === Comparator.ANY) {
|
|
3972
4009
|
continue;
|
|
3973
4010
|
}
|
|
3974
|
-
if (set[
|
|
3975
|
-
const allowed = set[
|
|
4011
|
+
if (set[i3].semver.prerelease.length > 0) {
|
|
4012
|
+
const allowed = set[i3].semver;
|
|
3976
4013
|
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
3977
4014
|
return true;
|
|
3978
4015
|
}
|
|
@@ -4306,7 +4343,7 @@ var require_libvips = __commonJS({
|
|
|
4306
4343
|
}
|
|
4307
4344
|
return false;
|
|
4308
4345
|
};
|
|
4309
|
-
var sha512 = (
|
|
4346
|
+
var sha512 = (s) => createHash("sha512").update(s).digest("hex");
|
|
4310
4347
|
var yarnLocator = () => {
|
|
4311
4348
|
try {
|
|
4312
4349
|
const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);
|
|
@@ -4780,7 +4817,7 @@ var require_input = __commonJS({
|
|
|
4780
4817
|
"tiffSubifd"
|
|
4781
4818
|
];
|
|
4782
4819
|
function _inputOptionsFromObject(obj) {
|
|
4783
|
-
const params = inputStreamParameters.filter((
|
|
4820
|
+
const params = inputStreamParameters.filter((p3) => is.defined(obj[p3])).map((p3) => [p3, obj[p3]]);
|
|
4784
4821
|
return params.length ? Object.fromEntries(params) : void 0;
|
|
4785
4822
|
}
|
|
4786
4823
|
function _createInputDescriptor(input, inputOptions, containerOptions) {
|
|
@@ -4820,7 +4857,7 @@ var require_input = __commonJS({
|
|
|
4820
4857
|
if (input.length > 1) {
|
|
4821
4858
|
if (!this.options.joining) {
|
|
4822
4859
|
this.options.joining = true;
|
|
4823
|
-
this.options.join = input.map((
|
|
4860
|
+
this.options.join = input.map((i3) => this._createInputDescriptor(i3));
|
|
4824
4861
|
} else {
|
|
4825
4862
|
throw new Error("Recursive join is unsupported");
|
|
4826
4863
|
}
|
|
@@ -6422,14 +6459,14 @@ var require_color = __commonJS({
|
|
|
6422
6459
|
const keyword = /^(\w+)$/;
|
|
6423
6460
|
let rgb = [0, 0, 0, 1];
|
|
6424
6461
|
let match;
|
|
6425
|
-
let
|
|
6462
|
+
let i3;
|
|
6426
6463
|
let hexAlpha;
|
|
6427
6464
|
if (match = string.match(hex)) {
|
|
6428
6465
|
hexAlpha = match[2];
|
|
6429
6466
|
match = match[1];
|
|
6430
|
-
for (
|
|
6431
|
-
const i22 =
|
|
6432
|
-
rgb[
|
|
6467
|
+
for (i3 = 0; i3 < 3; i3++) {
|
|
6468
|
+
const i22 = i3 * 2;
|
|
6469
|
+
rgb[i3] = Number.parseInt(match.slice(i22, i22 + 2), 16);
|
|
6433
6470
|
}
|
|
6434
6471
|
if (hexAlpha) {
|
|
6435
6472
|
rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
|
|
@@ -6437,22 +6474,22 @@ var require_color = __commonJS({
|
|
|
6437
6474
|
} else if (match = string.match(abbr)) {
|
|
6438
6475
|
match = match[1];
|
|
6439
6476
|
hexAlpha = match[3];
|
|
6440
|
-
for (
|
|
6441
|
-
rgb[
|
|
6477
|
+
for (i3 = 0; i3 < 3; i3++) {
|
|
6478
|
+
rgb[i3] = Number.parseInt(match[i3] + match[i3], 16);
|
|
6442
6479
|
}
|
|
6443
6480
|
if (hexAlpha) {
|
|
6444
6481
|
rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
6445
6482
|
}
|
|
6446
6483
|
} else if (match = string.match(rgba)) {
|
|
6447
|
-
for (
|
|
6448
|
-
rgb[
|
|
6484
|
+
for (i3 = 0; i3 < 3; i3++) {
|
|
6485
|
+
rgb[i3] = Number.parseInt(match[i3 + 1], 10);
|
|
6449
6486
|
}
|
|
6450
6487
|
if (match[4]) {
|
|
6451
6488
|
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
6452
6489
|
}
|
|
6453
6490
|
} else if (match = string.match(per)) {
|
|
6454
|
-
for (
|
|
6455
|
-
rgb[
|
|
6491
|
+
for (i3 = 0; i3 < 3; i3++) {
|
|
6492
|
+
rgb[i3] = Math.round(Number.parseFloat(match[i3 + 1]) * 2.55);
|
|
6456
6493
|
}
|
|
6457
6494
|
if (match[4]) {
|
|
6458
6495
|
rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
|
|
@@ -6470,8 +6507,8 @@ var require_color = __commonJS({
|
|
|
6470
6507
|
} else {
|
|
6471
6508
|
return null;
|
|
6472
6509
|
}
|
|
6473
|
-
for (
|
|
6474
|
-
rgb[
|
|
6510
|
+
for (i3 = 0; i3 < 3; i3++) {
|
|
6511
|
+
rgb[i3] = clamp(rgb[i3], 0, 255);
|
|
6475
6512
|
}
|
|
6476
6513
|
rgb[3] = clamp(rgb[3], 0, 1);
|
|
6477
6514
|
return rgb;
|
|
@@ -6484,11 +6521,11 @@ var require_color = __commonJS({
|
|
|
6484
6521
|
const match = string.match(hsl);
|
|
6485
6522
|
if (match) {
|
|
6486
6523
|
const alpha = Number.parseFloat(match[4]);
|
|
6487
|
-
const
|
|
6488
|
-
const
|
|
6489
|
-
const
|
|
6524
|
+
const h4 = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
6525
|
+
const s = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
6526
|
+
const l2 = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
6490
6527
|
const a2 = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
6491
|
-
return [
|
|
6528
|
+
return [h4, s, l2, a2];
|
|
6492
6529
|
}
|
|
6493
6530
|
return null;
|
|
6494
6531
|
};
|
|
@@ -6500,11 +6537,11 @@ var require_color = __commonJS({
|
|
|
6500
6537
|
const match = string.match(hwb);
|
|
6501
6538
|
if (match) {
|
|
6502
6539
|
const alpha = Number.parseFloat(match[4]);
|
|
6503
|
-
const
|
|
6540
|
+
const h4 = (Number.parseFloat(match[1]) % 360 + 360) % 360;
|
|
6504
6541
|
const w = clamp(Number.parseFloat(match[2]), 0, 100);
|
|
6505
6542
|
const b = clamp(Number.parseFloat(match[3]), 0, 100);
|
|
6506
6543
|
const a2 = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
6507
|
-
return [
|
|
6544
|
+
return [h4, w, b, a2];
|
|
6508
6545
|
}
|
|
6509
6546
|
return null;
|
|
6510
6547
|
};
|
|
@@ -6566,12 +6603,12 @@ var require_color = __commonJS({
|
|
|
6566
6603
|
};
|
|
6567
6604
|
var conversions_default = convert;
|
|
6568
6605
|
var LAB_FT = (6 / 29) ** 3;
|
|
6569
|
-
function srgbNonlinearTransform(
|
|
6570
|
-
const cc =
|
|
6606
|
+
function srgbNonlinearTransform(c3) {
|
|
6607
|
+
const cc = c3 > 31308e-7 ? 1.055 * c3 ** (1 / 2.4) - 0.055 : c3 * 12.92;
|
|
6571
6608
|
return Math.min(Math.max(0, cc), 1);
|
|
6572
6609
|
}
|
|
6573
|
-
function srgbNonlinearTransformInv(
|
|
6574
|
-
return
|
|
6610
|
+
function srgbNonlinearTransformInv(c3) {
|
|
6611
|
+
return c3 > 0.04045 ? ((c3 + 0.055) / 1.055) ** 2.4 : c3 / 12.92;
|
|
6575
6612
|
}
|
|
6576
6613
|
for (const model of Object.keys(convert)) {
|
|
6577
6614
|
if (!("channels" in convert[model])) {
|
|
@@ -6596,85 +6633,85 @@ var require_color = __commonJS({
|
|
|
6596
6633
|
const min = Math.min(r, g2, b);
|
|
6597
6634
|
const max = Math.max(r, g2, b);
|
|
6598
6635
|
const delta = max - min;
|
|
6599
|
-
let
|
|
6600
|
-
let
|
|
6636
|
+
let h4;
|
|
6637
|
+
let s;
|
|
6601
6638
|
switch (max) {
|
|
6602
6639
|
case min: {
|
|
6603
|
-
|
|
6640
|
+
h4 = 0;
|
|
6604
6641
|
break;
|
|
6605
6642
|
}
|
|
6606
6643
|
case r: {
|
|
6607
|
-
|
|
6644
|
+
h4 = (g2 - b) / delta;
|
|
6608
6645
|
break;
|
|
6609
6646
|
}
|
|
6610
6647
|
case g2: {
|
|
6611
|
-
|
|
6648
|
+
h4 = 2 + (b - r) / delta;
|
|
6612
6649
|
break;
|
|
6613
6650
|
}
|
|
6614
6651
|
case b: {
|
|
6615
|
-
|
|
6652
|
+
h4 = 4 + (r - g2) / delta;
|
|
6616
6653
|
break;
|
|
6617
6654
|
}
|
|
6618
6655
|
}
|
|
6619
|
-
|
|
6620
|
-
if (
|
|
6621
|
-
|
|
6656
|
+
h4 = Math.min(h4 * 60, 360);
|
|
6657
|
+
if (h4 < 0) {
|
|
6658
|
+
h4 += 360;
|
|
6622
6659
|
}
|
|
6623
|
-
const
|
|
6660
|
+
const l2 = (min + max) / 2;
|
|
6624
6661
|
if (max === min) {
|
|
6625
|
-
|
|
6626
|
-
} else if (
|
|
6627
|
-
|
|
6662
|
+
s = 0;
|
|
6663
|
+
} else if (l2 <= 0.5) {
|
|
6664
|
+
s = delta / (max + min);
|
|
6628
6665
|
} else {
|
|
6629
|
-
|
|
6666
|
+
s = delta / (2 - max - min);
|
|
6630
6667
|
}
|
|
6631
|
-
return [
|
|
6668
|
+
return [h4, s * 100, l2 * 100];
|
|
6632
6669
|
};
|
|
6633
6670
|
convert.rgb.hsv = function(rgb) {
|
|
6634
6671
|
let rdif;
|
|
6635
6672
|
let gdif;
|
|
6636
6673
|
let bdif;
|
|
6637
|
-
let
|
|
6638
|
-
let
|
|
6674
|
+
let h4;
|
|
6675
|
+
let s;
|
|
6639
6676
|
const r = rgb[0] / 255;
|
|
6640
6677
|
const g2 = rgb[1] / 255;
|
|
6641
6678
|
const b = rgb[2] / 255;
|
|
6642
6679
|
const v = Math.max(r, g2, b);
|
|
6643
6680
|
const diff = v - Math.min(r, g2, b);
|
|
6644
|
-
const diffc = function(
|
|
6645
|
-
return (v -
|
|
6681
|
+
const diffc = function(c3) {
|
|
6682
|
+
return (v - c3) / 6 / diff + 1 / 2;
|
|
6646
6683
|
};
|
|
6647
6684
|
if (diff === 0) {
|
|
6648
|
-
|
|
6649
|
-
|
|
6685
|
+
h4 = 0;
|
|
6686
|
+
s = 0;
|
|
6650
6687
|
} else {
|
|
6651
|
-
|
|
6688
|
+
s = diff / v;
|
|
6652
6689
|
rdif = diffc(r);
|
|
6653
6690
|
gdif = diffc(g2);
|
|
6654
6691
|
bdif = diffc(b);
|
|
6655
6692
|
switch (v) {
|
|
6656
6693
|
case r: {
|
|
6657
|
-
|
|
6694
|
+
h4 = bdif - gdif;
|
|
6658
6695
|
break;
|
|
6659
6696
|
}
|
|
6660
6697
|
case g2: {
|
|
6661
|
-
|
|
6698
|
+
h4 = 1 / 3 + rdif - bdif;
|
|
6662
6699
|
break;
|
|
6663
6700
|
}
|
|
6664
6701
|
case b: {
|
|
6665
|
-
|
|
6702
|
+
h4 = 2 / 3 + gdif - rdif;
|
|
6666
6703
|
break;
|
|
6667
6704
|
}
|
|
6668
6705
|
}
|
|
6669
|
-
if (
|
|
6670
|
-
|
|
6671
|
-
} else if (
|
|
6672
|
-
|
|
6706
|
+
if (h4 < 0) {
|
|
6707
|
+
h4 += 1;
|
|
6708
|
+
} else if (h4 > 1) {
|
|
6709
|
+
h4 -= 1;
|
|
6673
6710
|
}
|
|
6674
6711
|
}
|
|
6675
6712
|
return [
|
|
6676
|
-
|
|
6677
|
-
|
|
6713
|
+
h4 * 360,
|
|
6714
|
+
s * 100,
|
|
6678
6715
|
v * 100
|
|
6679
6716
|
];
|
|
6680
6717
|
};
|
|
@@ -6682,10 +6719,10 @@ var require_color = __commonJS({
|
|
|
6682
6719
|
const r = rgb[0];
|
|
6683
6720
|
const g2 = rgb[1];
|
|
6684
6721
|
let b = rgb[2];
|
|
6685
|
-
const
|
|
6722
|
+
const h4 = convert.rgb.hsl(rgb)[0];
|
|
6686
6723
|
const w = 1 / 255 * Math.min(r, Math.min(g2, b));
|
|
6687
6724
|
b = 1 - 1 / 255 * Math.max(r, Math.max(g2, b));
|
|
6688
|
-
return [
|
|
6725
|
+
return [h4, w * 100, b * 100];
|
|
6689
6726
|
};
|
|
6690
6727
|
convert.rgb.oklab = function(rgb) {
|
|
6691
6728
|
const r = srgbNonlinearTransformInv(rgb[0] / 255);
|
|
@@ -6694,20 +6731,20 @@ var require_color = __commonJS({
|
|
|
6694
6731
|
const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g2 + 0.0514459929 * b);
|
|
6695
6732
|
const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g2 + 0.1073969566 * b);
|
|
6696
6733
|
const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g2 + 0.6299787005 * b);
|
|
6697
|
-
const
|
|
6734
|
+
const l2 = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
|
|
6698
6735
|
const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
|
|
6699
6736
|
const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
|
|
6700
|
-
return [
|
|
6737
|
+
return [l2 * 100, aa * 100, bb * 100];
|
|
6701
6738
|
};
|
|
6702
6739
|
convert.rgb.cmyk = function(rgb) {
|
|
6703
6740
|
const r = rgb[0] / 255;
|
|
6704
6741
|
const g2 = rgb[1] / 255;
|
|
6705
6742
|
const b = rgb[2] / 255;
|
|
6706
6743
|
const k = Math.min(1 - r, 1 - g2, 1 - b);
|
|
6707
|
-
const
|
|
6708
|
-
const
|
|
6744
|
+
const c3 = (1 - r - k) / (1 - k) || 0;
|
|
6745
|
+
const m3 = (1 - g2 - k) / (1 - k) || 0;
|
|
6709
6746
|
const y = (1 - b - k) / (1 - k) || 0;
|
|
6710
|
-
return [
|
|
6747
|
+
return [c3 * 100, m3 * 100, y * 100, k * 100];
|
|
6711
6748
|
};
|
|
6712
6749
|
function comparativeDistance(x, y) {
|
|
6713
6750
|
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
@@ -6752,26 +6789,26 @@ var require_color = __commonJS({
|
|
|
6752
6789
|
x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
6753
6790
|
y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
6754
6791
|
z2 = z2 > LAB_FT ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
|
|
6755
|
-
const
|
|
6792
|
+
const l2 = 116 * y - 16;
|
|
6756
6793
|
const a2 = 500 * (x - y);
|
|
6757
6794
|
const b = 200 * (y - z2);
|
|
6758
|
-
return [
|
|
6795
|
+
return [l2, a2, b];
|
|
6759
6796
|
};
|
|
6760
6797
|
convert.hsl.rgb = function(hsl) {
|
|
6761
|
-
const
|
|
6762
|
-
const
|
|
6763
|
-
const
|
|
6798
|
+
const h4 = hsl[0] / 360;
|
|
6799
|
+
const s = hsl[1] / 100;
|
|
6800
|
+
const l2 = hsl[2] / 100;
|
|
6764
6801
|
let t3;
|
|
6765
6802
|
let value;
|
|
6766
|
-
if (
|
|
6767
|
-
value =
|
|
6803
|
+
if (s === 0) {
|
|
6804
|
+
value = l2 * 255;
|
|
6768
6805
|
return [value, value, value];
|
|
6769
6806
|
}
|
|
6770
|
-
const t2 =
|
|
6771
|
-
const t1 = 2 *
|
|
6807
|
+
const t2 = l2 < 0.5 ? l2 * (1 + s) : l2 + s - l2 * s;
|
|
6808
|
+
const t1 = 2 * l2 - t2;
|
|
6772
6809
|
const rgb = [0, 0, 0];
|
|
6773
|
-
for (let
|
|
6774
|
-
t3 =
|
|
6810
|
+
for (let i3 = 0; i3 < 3; i3++) {
|
|
6811
|
+
t3 = h4 + 1 / 3 * -(i3 - 1);
|
|
6775
6812
|
if (t3 < 0) {
|
|
6776
6813
|
t3++;
|
|
6777
6814
|
}
|
|
@@ -6787,71 +6824,71 @@ var require_color = __commonJS({
|
|
|
6787
6824
|
} else {
|
|
6788
6825
|
value = t1;
|
|
6789
6826
|
}
|
|
6790
|
-
rgb[
|
|
6827
|
+
rgb[i3] = value * 255;
|
|
6791
6828
|
}
|
|
6792
6829
|
return rgb;
|
|
6793
6830
|
};
|
|
6794
6831
|
convert.hsl.hsv = function(hsl) {
|
|
6795
|
-
const
|
|
6796
|
-
let
|
|
6797
|
-
let
|
|
6798
|
-
let smin =
|
|
6799
|
-
const lmin = Math.max(
|
|
6800
|
-
|
|
6801
|
-
|
|
6832
|
+
const h4 = hsl[0];
|
|
6833
|
+
let s = hsl[1] / 100;
|
|
6834
|
+
let l2 = hsl[2] / 100;
|
|
6835
|
+
let smin = s;
|
|
6836
|
+
const lmin = Math.max(l2, 0.01);
|
|
6837
|
+
l2 *= 2;
|
|
6838
|
+
s *= l2 <= 1 ? l2 : 2 - l2;
|
|
6802
6839
|
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
6803
|
-
const v = (
|
|
6804
|
-
const sv =
|
|
6805
|
-
return [
|
|
6840
|
+
const v = (l2 + s) / 2;
|
|
6841
|
+
const sv = l2 === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l2 + s);
|
|
6842
|
+
return [h4, sv * 100, v * 100];
|
|
6806
6843
|
};
|
|
6807
6844
|
convert.hsv.rgb = function(hsv) {
|
|
6808
|
-
const
|
|
6809
|
-
const
|
|
6845
|
+
const h4 = hsv[0] / 60;
|
|
6846
|
+
const s = hsv[1] / 100;
|
|
6810
6847
|
let v = hsv[2] / 100;
|
|
6811
|
-
const hi = Math.floor(
|
|
6812
|
-
const f2 =
|
|
6813
|
-
const
|
|
6814
|
-
const q4 = 255 * v * (1 -
|
|
6815
|
-
const t = 255 * v * (1 -
|
|
6848
|
+
const hi = Math.floor(h4) % 6;
|
|
6849
|
+
const f2 = h4 - Math.floor(h4);
|
|
6850
|
+
const p3 = 255 * v * (1 - s);
|
|
6851
|
+
const q4 = 255 * v * (1 - s * f2);
|
|
6852
|
+
const t = 255 * v * (1 - s * (1 - f2));
|
|
6816
6853
|
v *= 255;
|
|
6817
6854
|
switch (hi) {
|
|
6818
6855
|
case 0: {
|
|
6819
|
-
return [v, t,
|
|
6856
|
+
return [v, t, p3];
|
|
6820
6857
|
}
|
|
6821
6858
|
case 1: {
|
|
6822
|
-
return [q4, v,
|
|
6859
|
+
return [q4, v, p3];
|
|
6823
6860
|
}
|
|
6824
6861
|
case 2: {
|
|
6825
|
-
return [
|
|
6862
|
+
return [p3, v, t];
|
|
6826
6863
|
}
|
|
6827
6864
|
case 3: {
|
|
6828
|
-
return [
|
|
6865
|
+
return [p3, q4, v];
|
|
6829
6866
|
}
|
|
6830
6867
|
case 4: {
|
|
6831
|
-
return [t,
|
|
6868
|
+
return [t, p3, v];
|
|
6832
6869
|
}
|
|
6833
6870
|
case 5: {
|
|
6834
|
-
return [v,
|
|
6871
|
+
return [v, p3, q4];
|
|
6835
6872
|
}
|
|
6836
6873
|
}
|
|
6837
6874
|
};
|
|
6838
6875
|
convert.hsv.hsl = function(hsv) {
|
|
6839
|
-
const
|
|
6840
|
-
const
|
|
6876
|
+
const h4 = hsv[0];
|
|
6877
|
+
const s = hsv[1] / 100;
|
|
6841
6878
|
const v = hsv[2] / 100;
|
|
6842
6879
|
const vmin = Math.max(v, 0.01);
|
|
6843
6880
|
let sl;
|
|
6844
|
-
let
|
|
6845
|
-
|
|
6846
|
-
const lmin = (2 -
|
|
6847
|
-
sl =
|
|
6881
|
+
let l2;
|
|
6882
|
+
l2 = (2 - s) * v;
|
|
6883
|
+
const lmin = (2 - s) * vmin;
|
|
6884
|
+
sl = s * vmin;
|
|
6848
6885
|
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
6849
6886
|
sl = sl || 0;
|
|
6850
|
-
|
|
6851
|
-
return [
|
|
6887
|
+
l2 /= 2;
|
|
6888
|
+
return [h4, sl * 100, l2 * 100];
|
|
6852
6889
|
};
|
|
6853
6890
|
convert.hwb.rgb = function(hwb) {
|
|
6854
|
-
const
|
|
6891
|
+
const h4 = hwb[0] / 360;
|
|
6855
6892
|
let wh = hwb[1] / 100;
|
|
6856
6893
|
let bl = hwb[2] / 100;
|
|
6857
6894
|
const ratio = wh + bl;
|
|
@@ -6860,27 +6897,27 @@ var require_color = __commonJS({
|
|
|
6860
6897
|
wh /= ratio;
|
|
6861
6898
|
bl /= ratio;
|
|
6862
6899
|
}
|
|
6863
|
-
const
|
|
6900
|
+
const i3 = Math.floor(6 * h4);
|
|
6864
6901
|
const v = 1 - bl;
|
|
6865
|
-
f2 = 6 *
|
|
6866
|
-
if ((
|
|
6902
|
+
f2 = 6 * h4 - i3;
|
|
6903
|
+
if ((i3 & 1) !== 0) {
|
|
6867
6904
|
f2 = 1 - f2;
|
|
6868
6905
|
}
|
|
6869
|
-
const
|
|
6906
|
+
const n3 = wh + f2 * (v - wh);
|
|
6870
6907
|
let r;
|
|
6871
6908
|
let g2;
|
|
6872
6909
|
let b;
|
|
6873
|
-
switch (
|
|
6910
|
+
switch (i3) {
|
|
6874
6911
|
default:
|
|
6875
6912
|
case 6:
|
|
6876
6913
|
case 0: {
|
|
6877
6914
|
r = v;
|
|
6878
|
-
g2 =
|
|
6915
|
+
g2 = n3;
|
|
6879
6916
|
b = wh;
|
|
6880
6917
|
break;
|
|
6881
6918
|
}
|
|
6882
6919
|
case 1: {
|
|
6883
|
-
r =
|
|
6920
|
+
r = n3;
|
|
6884
6921
|
g2 = v;
|
|
6885
6922
|
b = wh;
|
|
6886
6923
|
break;
|
|
@@ -6888,17 +6925,17 @@ var require_color = __commonJS({
|
|
|
6888
6925
|
case 2: {
|
|
6889
6926
|
r = wh;
|
|
6890
6927
|
g2 = v;
|
|
6891
|
-
b =
|
|
6928
|
+
b = n3;
|
|
6892
6929
|
break;
|
|
6893
6930
|
}
|
|
6894
6931
|
case 3: {
|
|
6895
6932
|
r = wh;
|
|
6896
|
-
g2 =
|
|
6933
|
+
g2 = n3;
|
|
6897
6934
|
b = v;
|
|
6898
6935
|
break;
|
|
6899
6936
|
}
|
|
6900
6937
|
case 4: {
|
|
6901
|
-
r =
|
|
6938
|
+
r = n3;
|
|
6902
6939
|
g2 = wh;
|
|
6903
6940
|
b = v;
|
|
6904
6941
|
break;
|
|
@@ -6906,19 +6943,19 @@ var require_color = __commonJS({
|
|
|
6906
6943
|
case 5: {
|
|
6907
6944
|
r = v;
|
|
6908
6945
|
g2 = wh;
|
|
6909
|
-
b =
|
|
6946
|
+
b = n3;
|
|
6910
6947
|
break;
|
|
6911
6948
|
}
|
|
6912
6949
|
}
|
|
6913
6950
|
return [r * 255, g2 * 255, b * 255];
|
|
6914
6951
|
};
|
|
6915
6952
|
convert.cmyk.rgb = function(cmyk) {
|
|
6916
|
-
const
|
|
6917
|
-
const
|
|
6953
|
+
const c3 = cmyk[0] / 100;
|
|
6954
|
+
const m3 = cmyk[1] / 100;
|
|
6918
6955
|
const y = cmyk[2] / 100;
|
|
6919
6956
|
const k = cmyk[3] / 100;
|
|
6920
|
-
const r = 1 - Math.min(1,
|
|
6921
|
-
const g2 = 1 - Math.min(1,
|
|
6957
|
+
const r = 1 - Math.min(1, c3 * (1 - k) + k);
|
|
6958
|
+
const g2 = 1 - Math.min(1, m3 * (1 - k) + k);
|
|
6922
6959
|
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
6923
6960
|
return [r * 255, g2 * 255, b * 255];
|
|
6924
6961
|
};
|
|
@@ -6947,10 +6984,10 @@ var require_color = __commonJS({
|
|
|
6947
6984
|
x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
6948
6985
|
y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
6949
6986
|
z2 = z2 > LAB_FT ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
|
|
6950
|
-
const
|
|
6987
|
+
const l2 = 116 * y - 16;
|
|
6951
6988
|
const a2 = 500 * (x - y);
|
|
6952
6989
|
const b = 200 * (y - z2);
|
|
6953
|
-
return [
|
|
6990
|
+
return [l2, a2, b];
|
|
6954
6991
|
};
|
|
6955
6992
|
convert.xyz.oklab = function(xyz) {
|
|
6956
6993
|
const x = xyz[0] / 100;
|
|
@@ -6959,10 +6996,10 @@ var require_color = __commonJS({
|
|
|
6959
6996
|
const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z2);
|
|
6960
6997
|
const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z2);
|
|
6961
6998
|
const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z2);
|
|
6962
|
-
const
|
|
6999
|
+
const l2 = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
|
|
6963
7000
|
const a2 = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
|
|
6964
7001
|
const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
|
|
6965
|
-
return [
|
|
7002
|
+
return [l2 * 100, a2 * 100, b * 100];
|
|
6966
7003
|
};
|
|
6967
7004
|
convert.oklab.oklch = function(oklab) {
|
|
6968
7005
|
return convert.lab.lch(oklab);
|
|
@@ -6971,37 +7008,37 @@ var require_color = __commonJS({
|
|
|
6971
7008
|
const ll = oklab[0] / 100;
|
|
6972
7009
|
const a2 = oklab[1] / 100;
|
|
6973
7010
|
const b = oklab[2] / 100;
|
|
6974
|
-
const
|
|
6975
|
-
const
|
|
6976
|
-
const
|
|
6977
|
-
const x = 1.227013851 *
|
|
6978
|
-
const y = -0.040580178 *
|
|
6979
|
-
const z2 = -0.076381285 *
|
|
7011
|
+
const l2 = (0.999999998 * ll + 0.396337792 * a2 + 0.215803758 * b) ** 3;
|
|
7012
|
+
const m3 = (1.000000008 * ll - 0.105561342 * a2 - 0.063854175 * b) ** 3;
|
|
7013
|
+
const s = (1.000000055 * ll - 0.089484182 * a2 - 1.291485538 * b) ** 3;
|
|
7014
|
+
const x = 1.227013851 * l2 - 0.55779998 * m3 + 0.281256149 * s;
|
|
7015
|
+
const y = -0.040580178 * l2 + 1.11225687 * m3 - 0.071676679 * s;
|
|
7016
|
+
const z2 = -0.076381285 * l2 - 0.421481978 * m3 + 1.58616322 * s;
|
|
6980
7017
|
return [x * 100, y * 100, z2 * 100];
|
|
6981
7018
|
};
|
|
6982
7019
|
convert.oklab.rgb = function(oklab) {
|
|
6983
7020
|
const ll = oklab[0] / 100;
|
|
6984
7021
|
const aa = oklab[1] / 100;
|
|
6985
7022
|
const bb = oklab[2] / 100;
|
|
6986
|
-
const
|
|
6987
|
-
const
|
|
6988
|
-
const
|
|
6989
|
-
const r = srgbNonlinearTransform(4.0767416621 *
|
|
6990
|
-
const g2 = srgbNonlinearTransform(-1.2684380046 *
|
|
6991
|
-
const b = srgbNonlinearTransform(-0.0041960863 *
|
|
7023
|
+
const l2 = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;
|
|
7024
|
+
const m3 = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;
|
|
7025
|
+
const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;
|
|
7026
|
+
const r = srgbNonlinearTransform(4.0767416621 * l2 - 3.3077115913 * m3 + 0.2309699292 * s);
|
|
7027
|
+
const g2 = srgbNonlinearTransform(-1.2684380046 * l2 + 2.6097574011 * m3 - 0.3413193965 * s);
|
|
7028
|
+
const b = srgbNonlinearTransform(-0.0041960863 * l2 - 0.7034186147 * m3 + 1.707614701 * s);
|
|
6992
7029
|
return [r * 255, g2 * 255, b * 255];
|
|
6993
7030
|
};
|
|
6994
7031
|
convert.oklch.oklab = function(oklch) {
|
|
6995
7032
|
return convert.lch.lab(oklch);
|
|
6996
7033
|
};
|
|
6997
7034
|
convert.lab.xyz = function(lab) {
|
|
6998
|
-
const
|
|
7035
|
+
const l2 = lab[0];
|
|
6999
7036
|
const a2 = lab[1];
|
|
7000
7037
|
const b = lab[2];
|
|
7001
7038
|
let x;
|
|
7002
7039
|
let y;
|
|
7003
7040
|
let z2;
|
|
7004
|
-
y = (
|
|
7041
|
+
y = (l2 + 16) / 116;
|
|
7005
7042
|
x = a2 / 500 + y;
|
|
7006
7043
|
z2 = y - b / 200;
|
|
7007
7044
|
const y2 = y ** 3;
|
|
@@ -7016,26 +7053,26 @@ var require_color = __commonJS({
|
|
|
7016
7053
|
return [x, y, z2];
|
|
7017
7054
|
};
|
|
7018
7055
|
convert.lab.lch = function(lab) {
|
|
7019
|
-
const
|
|
7056
|
+
const l2 = lab[0];
|
|
7020
7057
|
const a2 = lab[1];
|
|
7021
7058
|
const b = lab[2];
|
|
7022
|
-
let
|
|
7059
|
+
let h4;
|
|
7023
7060
|
const hr = Math.atan2(b, a2);
|
|
7024
|
-
|
|
7025
|
-
if (
|
|
7026
|
-
|
|
7061
|
+
h4 = hr * 360 / 2 / Math.PI;
|
|
7062
|
+
if (h4 < 0) {
|
|
7063
|
+
h4 += 360;
|
|
7027
7064
|
}
|
|
7028
|
-
const
|
|
7029
|
-
return [
|
|
7065
|
+
const c3 = Math.sqrt(a2 * a2 + b * b);
|
|
7066
|
+
return [l2, c3, h4];
|
|
7030
7067
|
};
|
|
7031
7068
|
convert.lch.lab = function(lch) {
|
|
7032
|
-
const
|
|
7033
|
-
const
|
|
7034
|
-
const
|
|
7035
|
-
const hr =
|
|
7036
|
-
const a2 =
|
|
7037
|
-
const b =
|
|
7038
|
-
return [
|
|
7069
|
+
const l2 = lch[0];
|
|
7070
|
+
const c3 = lch[1];
|
|
7071
|
+
const h4 = lch[2];
|
|
7072
|
+
const hr = h4 / 360 * 2 * Math.PI;
|
|
7073
|
+
const a2 = c3 * Math.cos(hr);
|
|
7074
|
+
const b = c3 * Math.sin(hr);
|
|
7075
|
+
return [l2, a2, b];
|
|
7039
7076
|
};
|
|
7040
7077
|
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
7041
7078
|
const [r, g2, b] = args;
|
|
@@ -7088,8 +7125,8 @@ var require_color = __commonJS({
|
|
|
7088
7125
|
convert.ansi256.rgb = function(args) {
|
|
7089
7126
|
args = args[0];
|
|
7090
7127
|
if (args >= 232) {
|
|
7091
|
-
const
|
|
7092
|
-
return [
|
|
7128
|
+
const c3 = (args - 232) * 10 + 8;
|
|
7129
|
+
return [c3, c3, c3];
|
|
7093
7130
|
}
|
|
7094
7131
|
args -= 16;
|
|
7095
7132
|
let rem;
|
|
@@ -7141,34 +7178,34 @@ var require_color = __commonJS({
|
|
|
7141
7178
|
return [hue * 360, chroma * 100, grayscale * 100];
|
|
7142
7179
|
};
|
|
7143
7180
|
convert.hsl.hcg = function(hsl) {
|
|
7144
|
-
const
|
|
7145
|
-
const
|
|
7146
|
-
const
|
|
7181
|
+
const s = hsl[1] / 100;
|
|
7182
|
+
const l2 = hsl[2] / 100;
|
|
7183
|
+
const c3 = l2 < 0.5 ? 2 * s * l2 : 2 * s * (1 - l2);
|
|
7147
7184
|
let f2 = 0;
|
|
7148
|
-
if (
|
|
7149
|
-
f2 = (
|
|
7185
|
+
if (c3 < 1) {
|
|
7186
|
+
f2 = (l2 - 0.5 * c3) / (1 - c3);
|
|
7150
7187
|
}
|
|
7151
|
-
return [hsl[0],
|
|
7188
|
+
return [hsl[0], c3 * 100, f2 * 100];
|
|
7152
7189
|
};
|
|
7153
7190
|
convert.hsv.hcg = function(hsv) {
|
|
7154
|
-
const
|
|
7191
|
+
const s = hsv[1] / 100;
|
|
7155
7192
|
const v = hsv[2] / 100;
|
|
7156
|
-
const
|
|
7193
|
+
const c3 = s * v;
|
|
7157
7194
|
let f2 = 0;
|
|
7158
|
-
if (
|
|
7159
|
-
f2 = (v -
|
|
7195
|
+
if (c3 < 1) {
|
|
7196
|
+
f2 = (v - c3) / (1 - c3);
|
|
7160
7197
|
}
|
|
7161
|
-
return [hsv[0],
|
|
7198
|
+
return [hsv[0], c3 * 100, f2 * 100];
|
|
7162
7199
|
};
|
|
7163
7200
|
convert.hcg.rgb = function(hcg) {
|
|
7164
|
-
const
|
|
7165
|
-
const
|
|
7201
|
+
const h4 = hcg[0] / 360;
|
|
7202
|
+
const c3 = hcg[1] / 100;
|
|
7166
7203
|
const g2 = hcg[2] / 100;
|
|
7167
|
-
if (
|
|
7204
|
+
if (c3 === 0) {
|
|
7168
7205
|
return [g2 * 255, g2 * 255, g2 * 255];
|
|
7169
7206
|
}
|
|
7170
7207
|
const pure = [0, 0, 0];
|
|
7171
|
-
const hi =
|
|
7208
|
+
const hi = h4 % 1 * 6;
|
|
7172
7209
|
const v = hi % 1;
|
|
7173
7210
|
const w = 1 - v;
|
|
7174
7211
|
let mg = 0;
|
|
@@ -7209,51 +7246,51 @@ var require_color = __commonJS({
|
|
|
7209
7246
|
pure[2] = w;
|
|
7210
7247
|
}
|
|
7211
7248
|
}
|
|
7212
|
-
mg = (1 -
|
|
7249
|
+
mg = (1 - c3) * g2;
|
|
7213
7250
|
return [
|
|
7214
|
-
(
|
|
7215
|
-
(
|
|
7216
|
-
(
|
|
7251
|
+
(c3 * pure[0] + mg) * 255,
|
|
7252
|
+
(c3 * pure[1] + mg) * 255,
|
|
7253
|
+
(c3 * pure[2] + mg) * 255
|
|
7217
7254
|
];
|
|
7218
7255
|
};
|
|
7219
7256
|
convert.hcg.hsv = function(hcg) {
|
|
7220
|
-
const
|
|
7257
|
+
const c3 = hcg[1] / 100;
|
|
7221
7258
|
const g2 = hcg[2] / 100;
|
|
7222
|
-
const v =
|
|
7259
|
+
const v = c3 + g2 * (1 - c3);
|
|
7223
7260
|
let f2 = 0;
|
|
7224
7261
|
if (v > 0) {
|
|
7225
|
-
f2 =
|
|
7262
|
+
f2 = c3 / v;
|
|
7226
7263
|
}
|
|
7227
7264
|
return [hcg[0], f2 * 100, v * 100];
|
|
7228
7265
|
};
|
|
7229
7266
|
convert.hcg.hsl = function(hcg) {
|
|
7230
|
-
const
|
|
7267
|
+
const c3 = hcg[1] / 100;
|
|
7231
7268
|
const g2 = hcg[2] / 100;
|
|
7232
|
-
const
|
|
7233
|
-
let
|
|
7234
|
-
if (
|
|
7235
|
-
|
|
7236
|
-
} else if (
|
|
7237
|
-
|
|
7269
|
+
const l2 = g2 * (1 - c3) + 0.5 * c3;
|
|
7270
|
+
let s = 0;
|
|
7271
|
+
if (l2 > 0 && l2 < 0.5) {
|
|
7272
|
+
s = c3 / (2 * l2);
|
|
7273
|
+
} else if (l2 >= 0.5 && l2 < 1) {
|
|
7274
|
+
s = c3 / (2 * (1 - l2));
|
|
7238
7275
|
}
|
|
7239
|
-
return [hcg[0],
|
|
7276
|
+
return [hcg[0], s * 100, l2 * 100];
|
|
7240
7277
|
};
|
|
7241
7278
|
convert.hcg.hwb = function(hcg) {
|
|
7242
|
-
const
|
|
7279
|
+
const c3 = hcg[1] / 100;
|
|
7243
7280
|
const g2 = hcg[2] / 100;
|
|
7244
|
-
const v =
|
|
7245
|
-
return [hcg[0], (v -
|
|
7281
|
+
const v = c3 + g2 * (1 - c3);
|
|
7282
|
+
return [hcg[0], (v - c3) * 100, (1 - v) * 100];
|
|
7246
7283
|
};
|
|
7247
7284
|
convert.hwb.hcg = function(hwb) {
|
|
7248
7285
|
const w = hwb[1] / 100;
|
|
7249
7286
|
const b = hwb[2] / 100;
|
|
7250
7287
|
const v = 1 - b;
|
|
7251
|
-
const
|
|
7288
|
+
const c3 = v - w;
|
|
7252
7289
|
let g2 = 0;
|
|
7253
|
-
if (
|
|
7254
|
-
g2 = (v -
|
|
7290
|
+
if (c3 < 1) {
|
|
7291
|
+
g2 = (v - c3) / (1 - c3);
|
|
7255
7292
|
}
|
|
7256
|
-
return [hwb[0],
|
|
7293
|
+
return [hwb[0], c3 * 100, g2 * 100];
|
|
7257
7294
|
};
|
|
7258
7295
|
convert.apple.rgb = function(apple) {
|
|
7259
7296
|
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
@@ -7290,8 +7327,8 @@ var require_color = __commonJS({
|
|
|
7290
7327
|
function buildGraph() {
|
|
7291
7328
|
const graph = {};
|
|
7292
7329
|
const models2 = Object.keys(conversions_default);
|
|
7293
|
-
for (let { length } = models2,
|
|
7294
|
-
graph[models2[
|
|
7330
|
+
for (let { length } = models2, i3 = 0; i3 < length; i3++) {
|
|
7331
|
+
graph[models2[i3]] = {
|
|
7295
7332
|
// http://jsperf.com/1-vs-infinity
|
|
7296
7333
|
// micro-opt, but this is simple.
|
|
7297
7334
|
distance: -1,
|
|
@@ -7307,8 +7344,8 @@ var require_color = __commonJS({
|
|
|
7307
7344
|
while (queue.length > 0) {
|
|
7308
7345
|
const current = queue.pop();
|
|
7309
7346
|
const adjacents = Object.keys(conversions_default[current]);
|
|
7310
|
-
for (let { length } = adjacents,
|
|
7311
|
-
const adjacent = adjacents[
|
|
7347
|
+
for (let { length } = adjacents, i3 = 0; i3 < length; i3++) {
|
|
7348
|
+
const adjacent = adjacents[i3];
|
|
7312
7349
|
const node = graph[adjacent];
|
|
7313
7350
|
if (node.distance === -1) {
|
|
7314
7351
|
node.distance = graph[current].distance + 1;
|
|
@@ -7340,8 +7377,8 @@ var require_color = __commonJS({
|
|
|
7340
7377
|
const graph = deriveBFS(fromModel);
|
|
7341
7378
|
const conversion = {};
|
|
7342
7379
|
const models2 = Object.keys(graph);
|
|
7343
|
-
for (let { length } = models2,
|
|
7344
|
-
const toModel = models2[
|
|
7380
|
+
for (let { length } = models2, i3 = 0; i3 < length; i3++) {
|
|
7381
|
+
const toModel = models2[i3];
|
|
7345
7382
|
const node = graph[toModel];
|
|
7346
7383
|
if (node.parent === null) {
|
|
7347
7384
|
continue;
|
|
@@ -7380,8 +7417,8 @@ var require_color = __commonJS({
|
|
|
7380
7417
|
}
|
|
7381
7418
|
const result = fn(args);
|
|
7382
7419
|
if (typeof result === "object") {
|
|
7383
|
-
for (let { length } = result,
|
|
7384
|
-
result[
|
|
7420
|
+
for (let { length } = result, i3 = 0; i3 < length; i3++) {
|
|
7421
|
+
result[i3] = Math.round(result[i3]);
|
|
7385
7422
|
}
|
|
7386
7423
|
}
|
|
7387
7424
|
return result;
|
|
@@ -7427,7 +7464,7 @@ var require_color = __commonJS({
|
|
|
7427
7464
|
if (model && !(model in color_convert_default)) {
|
|
7428
7465
|
throw new Error("Unknown model: " + model);
|
|
7429
7466
|
}
|
|
7430
|
-
let
|
|
7467
|
+
let i3;
|
|
7431
7468
|
let channels;
|
|
7432
7469
|
if (object == null) {
|
|
7433
7470
|
this.model = "rgb";
|
|
@@ -7474,17 +7511,17 @@ var require_color = __commonJS({
|
|
|
7474
7511
|
this.model = hashedModelKeys[hashedKeys];
|
|
7475
7512
|
const { labels } = color_convert_default[this.model];
|
|
7476
7513
|
const color = [];
|
|
7477
|
-
for (
|
|
7478
|
-
color.push(object[labels[
|
|
7514
|
+
for (i3 = 0; i3 < labels.length; i3++) {
|
|
7515
|
+
color.push(object[labels[i3]]);
|
|
7479
7516
|
}
|
|
7480
7517
|
this.color = zeroArray(color);
|
|
7481
7518
|
}
|
|
7482
7519
|
if (limiters[this.model]) {
|
|
7483
7520
|
channels = color_convert_default[this.model].channels;
|
|
7484
|
-
for (
|
|
7485
|
-
const limit = limiters[this.model][
|
|
7521
|
+
for (i3 = 0; i3 < channels; i3++) {
|
|
7522
|
+
const limit = limiters[this.model][i3];
|
|
7486
7523
|
if (limit) {
|
|
7487
|
-
this.color[
|
|
7524
|
+
this.color[i3] = limit(this.color[i3]);
|
|
7488
7525
|
}
|
|
7489
7526
|
}
|
|
7490
7527
|
}
|
|
@@ -7501,14 +7538,14 @@ var require_color = __commonJS({
|
|
|
7501
7538
|
return this[this.model]();
|
|
7502
7539
|
},
|
|
7503
7540
|
string(places) {
|
|
7504
|
-
let
|
|
7505
|
-
|
|
7506
|
-
const arguments_ =
|
|
7507
|
-
return color_string_default.to[
|
|
7541
|
+
let self2 = this.model in color_string_default.to ? this : this.rgb();
|
|
7542
|
+
self2 = self2.round(typeof places === "number" ? places : 1);
|
|
7543
|
+
const arguments_ = self2.valpha === 1 ? self2.color : [...self2.color, this.valpha];
|
|
7544
|
+
return color_string_default.to[self2.model](...arguments_);
|
|
7508
7545
|
},
|
|
7509
7546
|
percentString(places) {
|
|
7510
|
-
const
|
|
7511
|
-
const arguments_ =
|
|
7547
|
+
const self2 = this.rgb().round(typeof places === "number" ? places : 1);
|
|
7548
|
+
const arguments_ = self2.valpha === 1 ? self2.color : [...self2.color, this.valpha];
|
|
7512
7549
|
return color_string_default.to.rgb.percent(...arguments_);
|
|
7513
7550
|
},
|
|
7514
7551
|
array() {
|
|
@@ -7518,8 +7555,8 @@ var require_color = __commonJS({
|
|
|
7518
7555
|
const result = {};
|
|
7519
7556
|
const { channels } = color_convert_default[this.model];
|
|
7520
7557
|
const { labels } = color_convert_default[this.model];
|
|
7521
|
-
for (let
|
|
7522
|
-
result[labels[
|
|
7558
|
+
for (let i3 = 0; i3 < channels; i3++) {
|
|
7559
|
+
result[labels[i3]] = this.color[i3];
|
|
7523
7560
|
}
|
|
7524
7561
|
if (this.valpha !== 1) {
|
|
7525
7562
|
result.alpha = this.valpha;
|
|
@@ -7609,9 +7646,9 @@ var require_color = __commonJS({
|
|
|
7609
7646
|
luminosity() {
|
|
7610
7647
|
const rgb = this.rgb().color;
|
|
7611
7648
|
const lum = [];
|
|
7612
|
-
for (const [
|
|
7649
|
+
for (const [i3, element] of rgb.entries()) {
|
|
7613
7650
|
const chan = element / 255;
|
|
7614
|
-
lum[
|
|
7651
|
+
lum[i3] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
|
|
7615
7652
|
}
|
|
7616
7653
|
return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
|
7617
7654
|
},
|
|
@@ -7640,8 +7677,8 @@ var require_color = __commonJS({
|
|
|
7640
7677
|
},
|
|
7641
7678
|
negate() {
|
|
7642
7679
|
const rgb = this.rgb();
|
|
7643
|
-
for (let
|
|
7644
|
-
rgb.color[
|
|
7680
|
+
for (let i3 = 0; i3 < 3; i3++) {
|
|
7681
|
+
rgb.color[i3] = 255 - rgb.color[i3];
|
|
7645
7682
|
}
|
|
7646
7683
|
return rgb;
|
|
7647
7684
|
},
|
|
@@ -7700,8 +7737,8 @@ var require_color = __commonJS({
|
|
|
7700
7737
|
}
|
|
7701
7738
|
const color1 = mixinColor.rgb();
|
|
7702
7739
|
const color2 = this.rgb();
|
|
7703
|
-
const
|
|
7704
|
-
const w = 2 *
|
|
7740
|
+
const p3 = weight === void 0 ? 0.5 : weight;
|
|
7741
|
+
const w = 2 * p3 - 1;
|
|
7705
7742
|
const a2 = color1.alpha() - color2.alpha();
|
|
7706
7743
|
const w1 = ((w * a2 === -1 ? w : (w + a2) / (1 + w * a2)) + 1) / 2;
|
|
7707
7744
|
const w2 = 1 - w1;
|
|
@@ -7709,7 +7746,7 @@ var require_color = __commonJS({
|
|
|
7709
7746
|
w1 * color1.red() + w2 * color2.red(),
|
|
7710
7747
|
w1 * color1.green() + w2 * color2.green(),
|
|
7711
7748
|
w1 * color1.blue() + w2 * color2.blue(),
|
|
7712
|
-
color1.alpha() *
|
|
7749
|
+
color1.alpha() * p3 + color2.alpha() * (1 - p3)
|
|
7713
7750
|
);
|
|
7714
7751
|
}
|
|
7715
7752
|
};
|
|
@@ -7745,8 +7782,8 @@ var require_color = __commonJS({
|
|
|
7745
7782
|
}
|
|
7746
7783
|
function getset(model, channel, modifier) {
|
|
7747
7784
|
model = Array.isArray(model) ? model : [model];
|
|
7748
|
-
for (const
|
|
7749
|
-
(limiters[
|
|
7785
|
+
for (const m3 of model) {
|
|
7786
|
+
(limiters[m3] || (limiters[m3] = []))[channel] = modifier;
|
|
7750
7787
|
}
|
|
7751
7788
|
model = model[0];
|
|
7752
7789
|
return function(value) {
|
|
@@ -7775,9 +7812,9 @@ var require_color = __commonJS({
|
|
|
7775
7812
|
return Array.isArray(value) ? value : [value];
|
|
7776
7813
|
}
|
|
7777
7814
|
function zeroArray(array, length) {
|
|
7778
|
-
for (let
|
|
7779
|
-
if (typeof array[
|
|
7780
|
-
array[
|
|
7815
|
+
for (let i3 = 0; i3 < length; i3++) {
|
|
7816
|
+
if (typeof array[i3] !== "number") {
|
|
7817
|
+
array[i3] = 0;
|
|
7781
7818
|
}
|
|
7782
7819
|
}
|
|
7783
7820
|
return array;
|
|
@@ -8966,24 +9003,24 @@ var require_lib = __commonJS({
|
|
|
8966
9003
|
// ../codec-sharp/dist/index.mjs
|
|
8967
9004
|
var dist_exports2 = {};
|
|
8968
9005
|
__export(dist_exports2, {
|
|
8969
|
-
|
|
8970
|
-
|
|
9006
|
+
codecSharp: () => o,
|
|
9007
|
+
default: () => f
|
|
8971
9008
|
});
|
|
8972
|
-
async function a(
|
|
9009
|
+
async function a(r) {
|
|
8973
9010
|
try {
|
|
8974
|
-
let
|
|
8975
|
-
if (!
|
|
8976
|
-
return { data:
|
|
8977
|
-
} catch (
|
|
8978
|
-
throw new Error(`Failed to read image file ${
|
|
9011
|
+
let e = await (0, import_sharp.default)(r).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
|
9012
|
+
if (!e.info.width || !e.info.height) throw new Error(`Invalid image dimensions: ${r}`);
|
|
9013
|
+
return { data: e.data, width: e.info.width, height: e.info.height };
|
|
9014
|
+
} catch (e) {
|
|
9015
|
+
throw new Error(`Failed to read image file ${r}: ${e}`);
|
|
8979
9016
|
}
|
|
8980
9017
|
}
|
|
8981
|
-
async function n(
|
|
9018
|
+
async function n(r, e) {
|
|
8982
9019
|
try {
|
|
8983
|
-
let t = (0, import_sharp.default)(
|
|
8984
|
-
typeof
|
|
9020
|
+
let t = (0, import_sharp.default)(r.data, { raw: { width: r.width, height: r.height, channels: 4 } });
|
|
9021
|
+
typeof e == "string" ? await t.png().toFile(e) : e.set(await t.png().toBuffer());
|
|
8985
9022
|
} catch (t) {
|
|
8986
|
-
throw new Error(`Failed to write image file ${
|
|
9023
|
+
throw new Error(`Failed to write image file ${e}: ${t}`);
|
|
8987
9024
|
}
|
|
8988
9025
|
}
|
|
8989
9026
|
var import_sharp, o, f;
|
|
@@ -8996,14 +9033,374 @@ var init_dist3 = __esm({
|
|
|
8996
9033
|
}
|
|
8997
9034
|
});
|
|
8998
9035
|
|
|
9036
|
+
// ../../node_modules/.pnpm/@jsquash+png@3.1.1/node_modules/@jsquash/png/codec/pkg/squoosh_png.js
|
|
9037
|
+
function addHeapObject(obj) {
|
|
9038
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
9039
|
+
const idx = heap_next;
|
|
9040
|
+
heap_next = heap[idx];
|
|
9041
|
+
heap[idx] = obj;
|
|
9042
|
+
return idx;
|
|
9043
|
+
}
|
|
9044
|
+
function getObject(idx) {
|
|
9045
|
+
return heap[idx];
|
|
9046
|
+
}
|
|
9047
|
+
function dropObject(idx) {
|
|
9048
|
+
if (idx < 132) return;
|
|
9049
|
+
heap[idx] = heap_next;
|
|
9050
|
+
heap_next = idx;
|
|
9051
|
+
}
|
|
9052
|
+
function takeObject(idx) {
|
|
9053
|
+
const ret = getObject(idx);
|
|
9054
|
+
dropObject(idx);
|
|
9055
|
+
return ret;
|
|
9056
|
+
}
|
|
9057
|
+
function getUint8Memory0() {
|
|
9058
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
9059
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
9060
|
+
}
|
|
9061
|
+
return cachedUint8Memory0;
|
|
9062
|
+
}
|
|
9063
|
+
function getStringFromWasm0(ptr, len) {
|
|
9064
|
+
ptr = ptr >>> 0;
|
|
9065
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
9066
|
+
}
|
|
9067
|
+
function getUint8ClampedMemory0() {
|
|
9068
|
+
if (cachedUint8ClampedMemory0 === null || cachedUint8ClampedMemory0.byteLength === 0) {
|
|
9069
|
+
cachedUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
|
|
9070
|
+
}
|
|
9071
|
+
return cachedUint8ClampedMemory0;
|
|
9072
|
+
}
|
|
9073
|
+
function getClampedArrayU8FromWasm0(ptr, len) {
|
|
9074
|
+
ptr = ptr >>> 0;
|
|
9075
|
+
return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
9076
|
+
}
|
|
9077
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
9078
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
9079
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
9080
|
+
WASM_VECTOR_LEN = arg.length;
|
|
9081
|
+
return ptr;
|
|
9082
|
+
}
|
|
9083
|
+
function getInt32Memory0() {
|
|
9084
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
9085
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
9086
|
+
}
|
|
9087
|
+
return cachedInt32Memory0;
|
|
9088
|
+
}
|
|
9089
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
9090
|
+
ptr = ptr >>> 0;
|
|
9091
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
9092
|
+
}
|
|
9093
|
+
function encode(data, width, height, bit_depth) {
|
|
9094
|
+
try {
|
|
9095
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
9096
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
9097
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9098
|
+
wasm.encode(retptr, ptr0, len0, width, height, bit_depth);
|
|
9099
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
9100
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
9101
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
9102
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
9103
|
+
return v2;
|
|
9104
|
+
} finally {
|
|
9105
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
9108
|
+
function decode(data) {
|
|
9109
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
9110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9111
|
+
const ret = wasm.decode(ptr0, len0);
|
|
9112
|
+
return takeObject(ret);
|
|
9113
|
+
}
|
|
9114
|
+
function decode_rgba16(data) {
|
|
9115
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
9116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
9117
|
+
const ret = wasm.decode_rgba16(ptr0, len0);
|
|
9118
|
+
return ImageDataRGBA16.__wrap(ret);
|
|
9119
|
+
}
|
|
9120
|
+
async function __wbg_load(module2, imports) {
|
|
9121
|
+
if (typeof Response === "function" && module2 instanceof Response) {
|
|
9122
|
+
if (typeof WebAssembly.instantiateStreaming === "function") {
|
|
9123
|
+
try {
|
|
9124
|
+
return await WebAssembly.instantiateStreaming(module2, imports);
|
|
9125
|
+
} catch (e) {
|
|
9126
|
+
if (module2.headers.get("Content-Type") != "application/wasm") {
|
|
9127
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
9128
|
+
} else {
|
|
9129
|
+
throw e;
|
|
9130
|
+
}
|
|
9131
|
+
}
|
|
9132
|
+
}
|
|
9133
|
+
const bytes = await module2.arrayBuffer();
|
|
9134
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
9135
|
+
} else {
|
|
9136
|
+
const instance = await WebAssembly.instantiate(module2, imports);
|
|
9137
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
9138
|
+
return { instance, module: module2 };
|
|
9139
|
+
} else {
|
|
9140
|
+
return instance;
|
|
9141
|
+
}
|
|
9142
|
+
}
|
|
9143
|
+
}
|
|
9144
|
+
function __wbg_get_imports() {
|
|
9145
|
+
const imports = {};
|
|
9146
|
+
imports.wbg = {};
|
|
9147
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
9148
|
+
const ret = wasm.memory;
|
|
9149
|
+
return addHeapObject(ret);
|
|
9150
|
+
};
|
|
9151
|
+
imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
|
|
9152
|
+
const ret = getObject(arg0).buffer;
|
|
9153
|
+
return addHeapObject(ret);
|
|
9154
|
+
};
|
|
9155
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_099217381c451830 = function(arg0, arg1, arg2) {
|
|
9156
|
+
const ret = new Uint16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
9157
|
+
return addHeapObject(ret);
|
|
9158
|
+
};
|
|
9159
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
9160
|
+
takeObject(arg0);
|
|
9161
|
+
};
|
|
9162
|
+
imports.wbg.__wbg_newwithownedu8clampedarrayandsh_91db5987993a08fb = function(arg0, arg1, arg2, arg3) {
|
|
9163
|
+
var v0 = getClampedArrayU8FromWasm0(arg0, arg1).slice();
|
|
9164
|
+
wasm.__wbindgen_free(arg0, arg1 * 1, 1);
|
|
9165
|
+
const ret = new ImageData(v0, arg2 >>> 0, arg3 >>> 0);
|
|
9166
|
+
return addHeapObject(ret);
|
|
9167
|
+
};
|
|
9168
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
9169
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
9170
|
+
};
|
|
9171
|
+
return imports;
|
|
9172
|
+
}
|
|
9173
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
9174
|
+
}
|
|
9175
|
+
function __wbg_finalize_init(instance, module2) {
|
|
9176
|
+
wasm = instance.exports;
|
|
9177
|
+
__wbg_init.__wbindgen_wasm_module = module2;
|
|
9178
|
+
cachedInt32Memory0 = null;
|
|
9179
|
+
cachedUint8Memory0 = null;
|
|
9180
|
+
cachedUint8ClampedMemory0 = null;
|
|
9181
|
+
return wasm;
|
|
9182
|
+
}
|
|
9183
|
+
async function __wbg_init(input) {
|
|
9184
|
+
if (wasm !== void 0) return wasm;
|
|
9185
|
+
if (typeof input === "undefined") {
|
|
9186
|
+
input = new URL("squoosh_png_bg.wasm", import_meta.url);
|
|
9187
|
+
}
|
|
9188
|
+
const imports = __wbg_get_imports();
|
|
9189
|
+
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
|
9190
|
+
input = fetch(input);
|
|
9191
|
+
}
|
|
9192
|
+
__wbg_init_memory(imports);
|
|
9193
|
+
const { instance, module: module2 } = await __wbg_load(await input, imports);
|
|
9194
|
+
return __wbg_finalize_init(instance, module2);
|
|
9195
|
+
}
|
|
9196
|
+
var import_meta, wasm, heap, heap_next, cachedTextDecoder, cachedUint8Memory0, cachedUint8ClampedMemory0, WASM_VECTOR_LEN, cachedInt32Memory0, ImageDataRGBA16, squoosh_png_default, isServiceWorker, isRunningInCloudFlareWorkers, isRunningInNode;
|
|
9197
|
+
var init_squoosh_png = __esm({
|
|
9198
|
+
"../../node_modules/.pnpm/@jsquash+png@3.1.1/node_modules/@jsquash/png/codec/pkg/squoosh_png.js"() {
|
|
9199
|
+
"use strict";
|
|
9200
|
+
import_meta = {};
|
|
9201
|
+
heap = new Array(128).fill(void 0);
|
|
9202
|
+
heap.push(void 0, null, true, false);
|
|
9203
|
+
heap_next = heap.length;
|
|
9204
|
+
cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) : { decode: () => {
|
|
9205
|
+
throw Error("TextDecoder not available");
|
|
9206
|
+
} };
|
|
9207
|
+
if (typeof TextDecoder !== "undefined") {
|
|
9208
|
+
cachedTextDecoder.decode();
|
|
9209
|
+
}
|
|
9210
|
+
cachedUint8Memory0 = null;
|
|
9211
|
+
cachedUint8ClampedMemory0 = null;
|
|
9212
|
+
WASM_VECTOR_LEN = 0;
|
|
9213
|
+
cachedInt32Memory0 = null;
|
|
9214
|
+
ImageDataRGBA16 = class _ImageDataRGBA16 {
|
|
9215
|
+
static __wrap(ptr) {
|
|
9216
|
+
ptr = ptr >>> 0;
|
|
9217
|
+
const obj = Object.create(_ImageDataRGBA16.prototype);
|
|
9218
|
+
obj.__wbg_ptr = ptr;
|
|
9219
|
+
return obj;
|
|
9220
|
+
}
|
|
9221
|
+
__destroy_into_raw() {
|
|
9222
|
+
const ptr = this.__wbg_ptr;
|
|
9223
|
+
this.__wbg_ptr = 0;
|
|
9224
|
+
return ptr;
|
|
9225
|
+
}
|
|
9226
|
+
free() {
|
|
9227
|
+
const ptr = this.__destroy_into_raw();
|
|
9228
|
+
wasm.__wbg_imagedatargba16_free(ptr);
|
|
9229
|
+
}
|
|
9230
|
+
/**
|
|
9231
|
+
* @returns {number}
|
|
9232
|
+
*/
|
|
9233
|
+
get width() {
|
|
9234
|
+
const ret = wasm.imagedatargba16_width(this.__wbg_ptr);
|
|
9235
|
+
return ret >>> 0;
|
|
9236
|
+
}
|
|
9237
|
+
/**
|
|
9238
|
+
* @returns {number}
|
|
9239
|
+
*/
|
|
9240
|
+
get height() {
|
|
9241
|
+
const ret = wasm.imagedatargba16_height(this.__wbg_ptr);
|
|
9242
|
+
return ret >>> 0;
|
|
9243
|
+
}
|
|
9244
|
+
/**
|
|
9245
|
+
* @returns {Uint16Array}
|
|
9246
|
+
*/
|
|
9247
|
+
get data() {
|
|
9248
|
+
const ret = wasm.imagedatargba16_data(this.__wbg_ptr);
|
|
9249
|
+
return takeObject(ret);
|
|
9250
|
+
}
|
|
9251
|
+
};
|
|
9252
|
+
squoosh_png_default = __wbg_init;
|
|
9253
|
+
isServiceWorker = globalThis.ServiceWorkerGlobalScope !== void 0;
|
|
9254
|
+
isRunningInCloudFlareWorkers = isServiceWorker && typeof self !== "undefined" && globalThis.caches && globalThis.caches.default !== void 0;
|
|
9255
|
+
isRunningInNode = typeof process === "object" && process.release && process.release.name === "node";
|
|
9256
|
+
if (isRunningInCloudFlareWorkers || isRunningInNode) {
|
|
9257
|
+
if (!globalThis.ImageData) {
|
|
9258
|
+
globalThis.ImageData = class ImageData {
|
|
9259
|
+
constructor(data, width, height) {
|
|
9260
|
+
this.data = data;
|
|
9261
|
+
this.width = width;
|
|
9262
|
+
this.height = height;
|
|
9263
|
+
}
|
|
9264
|
+
};
|
|
9265
|
+
}
|
|
9266
|
+
if (import_meta.url === void 0) {
|
|
9267
|
+
import_meta.url = "https://localhost";
|
|
9268
|
+
}
|
|
9269
|
+
if (typeof self !== "undefined" && self.location === void 0) {
|
|
9270
|
+
self.location = { href: "" };
|
|
9271
|
+
}
|
|
9272
|
+
}
|
|
9273
|
+
}
|
|
9274
|
+
});
|
|
9275
|
+
|
|
9276
|
+
// ../../node_modules/.pnpm/@jsquash+png@3.1.1/node_modules/@jsquash/png/decode.js
|
|
9277
|
+
var decode_exports = {};
|
|
9278
|
+
__export(decode_exports, {
|
|
9279
|
+
decode: () => decode2,
|
|
9280
|
+
default: () => decode_default,
|
|
9281
|
+
init: () => init
|
|
9282
|
+
});
|
|
9283
|
+
async function init(moduleOrPath) {
|
|
9284
|
+
if (!pngModule) {
|
|
9285
|
+
pngModule = squoosh_png_default(moduleOrPath);
|
|
9286
|
+
}
|
|
9287
|
+
return pngModule;
|
|
9288
|
+
}
|
|
9289
|
+
async function decode2(data, options = {}) {
|
|
9290
|
+
await init();
|
|
9291
|
+
const { bitDepth = 8 } = options;
|
|
9292
|
+
if (bitDepth === 16) {
|
|
9293
|
+
const imageData2 = await decode_rgba16(new Uint8Array(data));
|
|
9294
|
+
if (!imageData2)
|
|
9295
|
+
throw new Error("Encoding error.");
|
|
9296
|
+
return imageData2;
|
|
9297
|
+
}
|
|
9298
|
+
const imageData = await decode(new Uint8Array(data));
|
|
9299
|
+
if (!imageData)
|
|
9300
|
+
throw new Error("Encoding error.");
|
|
9301
|
+
return imageData;
|
|
9302
|
+
}
|
|
9303
|
+
var pngModule, decode_default;
|
|
9304
|
+
var init_decode = __esm({
|
|
9305
|
+
"../../node_modules/.pnpm/@jsquash+png@3.1.1/node_modules/@jsquash/png/decode.js"() {
|
|
9306
|
+
"use strict";
|
|
9307
|
+
init_squoosh_png();
|
|
9308
|
+
decode_default = decode2;
|
|
9309
|
+
}
|
|
9310
|
+
});
|
|
9311
|
+
|
|
9312
|
+
// ../../node_modules/.pnpm/@jsquash+png@3.1.1/node_modules/@jsquash/png/encode.js
|
|
9313
|
+
var encode_exports = {};
|
|
9314
|
+
__export(encode_exports, {
|
|
9315
|
+
default: () => encode2,
|
|
9316
|
+
init: () => init2
|
|
9317
|
+
});
|
|
9318
|
+
async function init2(moduleOrPath) {
|
|
9319
|
+
if (!pngModule2) {
|
|
9320
|
+
pngModule2 = squoosh_png_default(moduleOrPath);
|
|
9321
|
+
}
|
|
9322
|
+
return pngModule2;
|
|
9323
|
+
}
|
|
9324
|
+
async function encode2(data, options = {}) {
|
|
9325
|
+
var _a;
|
|
9326
|
+
await init2();
|
|
9327
|
+
const bitDepth = (_a = options === null || options === void 0 ? void 0 : options.bitDepth) !== null && _a !== void 0 ? _a : 8;
|
|
9328
|
+
if (bitDepth !== 8 && bitDepth !== 16) {
|
|
9329
|
+
throw new Error("Invalid bit depth. Must be either 8 or 16.");
|
|
9330
|
+
}
|
|
9331
|
+
const isUint16Array = data.data instanceof Uint16Array;
|
|
9332
|
+
if (isUint16Array && bitDepth !== 16) {
|
|
9333
|
+
throw new Error("Invalid bit depth, must be 16 for Uint16Array or manually convert to RGB8 values with Uint8Array.");
|
|
9334
|
+
}
|
|
9335
|
+
if (!isUint16Array && bitDepth === 16) {
|
|
9336
|
+
throw new Error("Invalid bit depth, must be 8 for Uint8Array or manually convert to RGB16 values with Uint16Array.");
|
|
9337
|
+
}
|
|
9338
|
+
const encodeData = new Uint8Array(data.data.buffer);
|
|
9339
|
+
const output = await encode(encodeData, data.width, data.height, bitDepth);
|
|
9340
|
+
if (!output)
|
|
9341
|
+
throw new Error("Encoding error.");
|
|
9342
|
+
return output.buffer;
|
|
9343
|
+
}
|
|
9344
|
+
var pngModule2;
|
|
9345
|
+
var init_encode = __esm({
|
|
9346
|
+
"../../node_modules/.pnpm/@jsquash+png@3.1.1/node_modules/@jsquash/png/encode.js"() {
|
|
9347
|
+
"use strict";
|
|
9348
|
+
init_squoosh_png();
|
|
9349
|
+
}
|
|
9350
|
+
});
|
|
9351
|
+
|
|
9352
|
+
// ../codec-jsquash-png/dist/index.mjs
|
|
9353
|
+
var dist_exports3 = {};
|
|
9354
|
+
__export(dist_exports3, {
|
|
9355
|
+
codecJsquashPng: () => l,
|
|
9356
|
+
default: () => p
|
|
9357
|
+
});
|
|
9358
|
+
function c2() {
|
|
9359
|
+
return n2 || (n2 = (async () => {
|
|
9360
|
+
let e = (0, import_path.dirname)(i2.resolve("@jsquash/png")), t = (0, import_path.join)(e, "codec", "pkg", "squoosh_png_bg.wasm"), a2 = (0, import_fs2.readFileSync)(t), o2 = await Promise.resolve().then(() => (init_decode(), decode_exports)), r = await Promise.resolve().then(() => (init_encode(), encode_exports));
|
|
9361
|
+
return await Promise.all([o2.init(a2), r.init(a2)]), { decode: o2.default, encode: r.default };
|
|
9362
|
+
})(), n2);
|
|
9363
|
+
}
|
|
9364
|
+
async function h2(e) {
|
|
9365
|
+
try {
|
|
9366
|
+
let { decode: t } = await c2(), a2 = typeof e == "string" ? (0, import_fs2.readFileSync)(e) : e, o2 = new Uint8Array(a2).buffer, r = await t(o2);
|
|
9367
|
+
return { data: r.data, width: r.width, height: r.height };
|
|
9368
|
+
} catch (t) {
|
|
9369
|
+
throw new Error(`Failed to read PNG file ${e}: ${t}`);
|
|
9370
|
+
}
|
|
9371
|
+
}
|
|
9372
|
+
async function m2(e, t) {
|
|
9373
|
+
try {
|
|
9374
|
+
let { encode: a2 } = await c2(), o2 = { data: new Uint8ClampedArray(e.data.buffer, e.data.byteOffset, e.data.byteLength), width: e.width, height: e.height, colorSpace: "srgb" }, r = await a2(o2);
|
|
9375
|
+
(0, import_fs2.writeFileSync)(t, Buffer.from(r));
|
|
9376
|
+
} catch (a2) {
|
|
9377
|
+
throw new Error(`Failed to write PNG file ${t}: ${a2}`);
|
|
9378
|
+
}
|
|
9379
|
+
}
|
|
9380
|
+
var import_fs2, import_path, i2, n2, l, p;
|
|
9381
|
+
var init_dist4 = __esm({
|
|
9382
|
+
"../codec-jsquash-png/dist/index.mjs"() {
|
|
9383
|
+
"use strict";
|
|
9384
|
+
import_fs2 = require("fs");
|
|
9385
|
+
import_path = require("path");
|
|
9386
|
+
i2 = ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (t, a2) => (typeof require < "u" ? require : t)[a2] }) : e)(function(e) {
|
|
9387
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
9388
|
+
throw Error('Dynamic require of "' + e + '" is not supported');
|
|
9389
|
+
});
|
|
9390
|
+
n2 = null;
|
|
9391
|
+
l = { read: h2, write: m2 };
|
|
9392
|
+
p = l;
|
|
9393
|
+
}
|
|
9394
|
+
});
|
|
9395
|
+
|
|
8999
9396
|
// src/commands/core.ts
|
|
9000
9397
|
var core_exports = {};
|
|
9001
9398
|
__export(core_exports, {
|
|
9002
9399
|
default: () => main2
|
|
9003
9400
|
});
|
|
9004
9401
|
function parseRGB(colorStr) {
|
|
9005
|
-
const parts = colorStr.split(",").map((
|
|
9006
|
-
if (parts.length !== 3 || parts.some((
|
|
9402
|
+
const parts = colorStr.split(",").map((s) => parseInt(s.trim(), 10));
|
|
9403
|
+
if (parts.length !== 3 || parts.some((p3) => Number.isNaN(p3) || p3 < 0 || p3 > 255)) {
|
|
9007
9404
|
throw new Error(
|
|
9008
9405
|
`Invalid RGB color format: ${colorStr}. Expected format: r,g,b (e.g., 255,0,0)`
|
|
9009
9406
|
);
|
|
@@ -9027,7 +9424,7 @@ Options:
|
|
|
9027
9424
|
--diff-color-alt <r,g,b> Alternative color for dark differences (default: same as diff-color)
|
|
9028
9425
|
--include-aa Include anti-aliasing detection
|
|
9029
9426
|
--diff-mask Draw diff over transparent background
|
|
9030
|
-
--
|
|
9427
|
+
--codec <name> Specify codec to use (pngjs, sharp, jsquash-png)
|
|
9031
9428
|
-h, --help Show this help message
|
|
9032
9429
|
|
|
9033
9430
|
Examples:
|
|
@@ -9051,15 +9448,15 @@ async function main2() {
|
|
|
9051
9448
|
const image1 = args[0];
|
|
9052
9449
|
const image2 = args[1];
|
|
9053
9450
|
const options = {};
|
|
9054
|
-
for (let
|
|
9055
|
-
const arg = args[
|
|
9056
|
-
const nextArg = args[
|
|
9451
|
+
for (let i3 = 2; i3 < args.length; i3++) {
|
|
9452
|
+
const arg = args[i3];
|
|
9453
|
+
const nextArg = args[i3 + 1];
|
|
9057
9454
|
switch (arg) {
|
|
9058
9455
|
case "-o":
|
|
9059
9456
|
case "--output":
|
|
9060
9457
|
if (nextArg) {
|
|
9061
9458
|
options.outputPath = nextArg;
|
|
9062
|
-
|
|
9459
|
+
i3++;
|
|
9063
9460
|
}
|
|
9064
9461
|
break;
|
|
9065
9462
|
case "-t":
|
|
@@ -9072,7 +9469,7 @@ async function main2() {
|
|
|
9072
9469
|
);
|
|
9073
9470
|
}
|
|
9074
9471
|
options.threshold = threshold;
|
|
9075
|
-
|
|
9472
|
+
i3++;
|
|
9076
9473
|
}
|
|
9077
9474
|
break;
|
|
9078
9475
|
case "-a":
|
|
@@ -9085,25 +9482,25 @@ async function main2() {
|
|
|
9085
9482
|
);
|
|
9086
9483
|
}
|
|
9087
9484
|
options.alpha = alpha;
|
|
9088
|
-
|
|
9485
|
+
i3++;
|
|
9089
9486
|
}
|
|
9090
9487
|
break;
|
|
9091
9488
|
case "--aa-color":
|
|
9092
9489
|
if (nextArg) {
|
|
9093
9490
|
options.aaColor = parseRGB(nextArg);
|
|
9094
|
-
|
|
9491
|
+
i3++;
|
|
9095
9492
|
}
|
|
9096
9493
|
break;
|
|
9097
9494
|
case "--diff-color":
|
|
9098
9495
|
if (nextArg) {
|
|
9099
9496
|
options.diffColor = parseRGB(nextArg);
|
|
9100
|
-
|
|
9497
|
+
i3++;
|
|
9101
9498
|
}
|
|
9102
9499
|
break;
|
|
9103
9500
|
case "--diff-color-alt":
|
|
9104
9501
|
if (nextArg) {
|
|
9105
9502
|
options.diffColorAlt = parseRGB(nextArg);
|
|
9106
|
-
|
|
9503
|
+
i3++;
|
|
9107
9504
|
}
|
|
9108
9505
|
break;
|
|
9109
9506
|
case "--include-aa":
|
|
@@ -9112,10 +9509,10 @@ async function main2() {
|
|
|
9112
9509
|
case "--diff-mask":
|
|
9113
9510
|
options.diffMask = true;
|
|
9114
9511
|
break;
|
|
9115
|
-
case "--
|
|
9512
|
+
case "--codec":
|
|
9116
9513
|
if (nextArg) {
|
|
9117
|
-
options.
|
|
9118
|
-
|
|
9514
|
+
options.codec = nextArg;
|
|
9515
|
+
i3++;
|
|
9119
9516
|
}
|
|
9120
9517
|
break;
|
|
9121
9518
|
default:
|
|
@@ -9124,12 +9521,10 @@ async function main2() {
|
|
|
9124
9521
|
process.exit(1);
|
|
9125
9522
|
}
|
|
9126
9523
|
}
|
|
9127
|
-
const
|
|
9128
|
-
options.transformer
|
|
9129
|
-
);
|
|
9524
|
+
const codec = await getCodec(options.codec);
|
|
9130
9525
|
const [img1, img2] = await Promise.all([
|
|
9131
|
-
|
|
9132
|
-
|
|
9526
|
+
codec.read(image1),
|
|
9527
|
+
codec.read(image2)
|
|
9133
9528
|
]);
|
|
9134
9529
|
if (img1.width !== img2.width || img1.height !== img2.height) {
|
|
9135
9530
|
throw new Error(
|
|
@@ -9160,7 +9555,7 @@ async function main2() {
|
|
|
9160
9555
|
);
|
|
9161
9556
|
const duration = performance.now() - startTime;
|
|
9162
9557
|
if (diffCount > 0 && options.outputPath && outputData) {
|
|
9163
|
-
await
|
|
9558
|
+
await codec.write(
|
|
9164
9559
|
{
|
|
9165
9560
|
data: outputData,
|
|
9166
9561
|
width: img1.width,
|
|
@@ -9198,21 +9593,25 @@ async function main2() {
|
|
|
9198
9593
|
process.exit(1);
|
|
9199
9594
|
}
|
|
9200
9595
|
}
|
|
9201
|
-
var
|
|
9596
|
+
var getCodec;
|
|
9202
9597
|
var init_core = __esm({
|
|
9203
9598
|
"src/commands/core.ts"() {
|
|
9204
9599
|
"use strict";
|
|
9205
9600
|
init_dist();
|
|
9206
|
-
|
|
9207
|
-
if (!
|
|
9208
|
-
const { default:
|
|
9209
|
-
return
|
|
9601
|
+
getCodec = async (codec) => {
|
|
9602
|
+
if (!codec || codec === "pngjs") {
|
|
9603
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
9604
|
+
return c3;
|
|
9605
|
+
}
|
|
9606
|
+
if (codec === "sharp") {
|
|
9607
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist3(), dist_exports2));
|
|
9608
|
+
return c3;
|
|
9210
9609
|
}
|
|
9211
|
-
if (
|
|
9212
|
-
const { default:
|
|
9213
|
-
return
|
|
9610
|
+
if (codec === "jsquash-png") {
|
|
9611
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist4(), dist_exports3));
|
|
9612
|
+
return c3;
|
|
9214
9613
|
}
|
|
9215
|
-
throw new Error(`Unknown
|
|
9614
|
+
throw new Error(`Unknown codec: ${codec}`);
|
|
9216
9615
|
};
|
|
9217
9616
|
if (typeof require !== "undefined" && require.main === module) {
|
|
9218
9617
|
main2();
|
|
@@ -9221,90 +9620,90 @@ var init_core = __esm({
|
|
|
9221
9620
|
});
|
|
9222
9621
|
|
|
9223
9622
|
// ../gmsd/dist/index.mjs
|
|
9224
|
-
function D(e,
|
|
9225
|
-
let { downsample:
|
|
9226
|
-
if (H(e,
|
|
9623
|
+
function D(e, n3, a2, t, r, o2 = {}) {
|
|
9624
|
+
let { downsample: s = 0, c: c3 = 170 } = o2;
|
|
9625
|
+
if (H(e, n3)) {
|
|
9227
9626
|
if (a2) for (let y = 0; y < t * r * 4; y += 4) a2[y] = 255, a2[y + 1] = 255, a2[y + 2] = 255, a2[y + 3] = 255;
|
|
9228
9627
|
return 0;
|
|
9229
9628
|
}
|
|
9230
|
-
let f2 = e.length / (t * r) === 4,
|
|
9231
|
-
if (f2)
|
|
9629
|
+
let f2 = e.length / (t * r) === 4, l2, u, b = t, x = r;
|
|
9630
|
+
if (f2) l2 = new Float32Array(t * r), u = new Float32Array(t * r), q2(e, l2, t, r), q2(n3, u, t, r);
|
|
9232
9631
|
else {
|
|
9233
|
-
|
|
9234
|
-
for (let y = 0; y < t * r; y++)
|
|
9632
|
+
l2 = new Float32Array(t * r), u = new Float32Array(t * r);
|
|
9633
|
+
for (let y = 0; y < t * r; y++) l2[y] = e[y], u[y] = n3[y];
|
|
9235
9634
|
}
|
|
9236
|
-
if (
|
|
9237
|
-
let y = P(
|
|
9238
|
-
for (let
|
|
9239
|
-
let G =
|
|
9240
|
-
M[
|
|
9635
|
+
if (s === 1) {
|
|
9636
|
+
let y = P(l2, t, r), B = P(u, t, r), d2 = Math.floor(t / 2), I2 = Math.floor(r / 2), M = new Float32Array(d2 * I2), v = new Float32Array(d2 * I2);
|
|
9637
|
+
for (let i3 = 0; i3 < I2; i3++) for (let p3 = 0; p3 < d2; p3++) {
|
|
9638
|
+
let G = i3 * 2 * t + p3 * 2;
|
|
9639
|
+
M[i3 * d2 + p3] = y[G], v[i3 * d2 + p3] = B[G];
|
|
9241
9640
|
}
|
|
9242
|
-
|
|
9641
|
+
l2 = M, u = v, b = d2, x = I2;
|
|
9243
9642
|
}
|
|
9244
|
-
let F2 = S(
|
|
9245
|
-
return a2 && O(a2, F2, A,
|
|
9643
|
+
let F2 = S(l2, b, x), A = S(u, b, x), g2 = U(F2, A, c3, b, x), k = W(g2);
|
|
9644
|
+
return a2 && O(a2, F2, A, c3, b, x), k;
|
|
9246
9645
|
}
|
|
9247
|
-
function H(e,
|
|
9248
|
-
if (e.length !==
|
|
9249
|
-
for (let a2 = 0; a2 < e.length; a2++) if (e[a2] !==
|
|
9646
|
+
function H(e, n3) {
|
|
9647
|
+
if (e.length !== n3.length) return false;
|
|
9648
|
+
for (let a2 = 0; a2 < e.length; a2++) if (e[a2] !== n3[a2]) return false;
|
|
9250
9649
|
return true;
|
|
9251
9650
|
}
|
|
9252
|
-
function P(e,
|
|
9253
|
-
let t = new Float32Array(
|
|
9254
|
-
for (let r = 0; r < a2; r++) for (let o2 = 0; o2 <
|
|
9255
|
-
let
|
|
9256
|
-
for (let
|
|
9257
|
-
let f2 = r +
|
|
9258
|
-
f2 < a2 &&
|
|
9651
|
+
function P(e, n3, a2) {
|
|
9652
|
+
let t = new Float32Array(n3 * a2);
|
|
9653
|
+
for (let r = 0; r < a2; r++) for (let o2 = 0; o2 < n3; o2++) {
|
|
9654
|
+
let s = 0;
|
|
9655
|
+
for (let c3 = 0; c3 < 2; c3++) for (let m3 = 0; m3 < 2; m3++) {
|
|
9656
|
+
let f2 = r + c3, l2 = o2 + m3;
|
|
9657
|
+
f2 < a2 && l2 < n3 && (s += e[f2 * n3 + l2]);
|
|
9259
9658
|
}
|
|
9260
|
-
t[r *
|
|
9659
|
+
t[r * n3 + o2] = s / 4;
|
|
9261
9660
|
}
|
|
9262
9661
|
return t;
|
|
9263
9662
|
}
|
|
9264
|
-
function O(e,
|
|
9663
|
+
function O(e, n3, a2, t, r, o2) {
|
|
9265
9664
|
e.fill(0);
|
|
9266
|
-
for (let
|
|
9267
|
-
let
|
|
9665
|
+
for (let s = 1; s < o2 - 1; s++) for (let c3 = 1; c3 < r - 1; c3++) {
|
|
9666
|
+
let m3 = s * r + c3, f2 = n3[m3], l2 = a2[m3], u = 2 * f2 * l2 + t, b = f2 * f2 + l2 * l2 + t, x = u / b, F2 = Math.floor(x * 255), A = m3 * 4;
|
|
9268
9667
|
e[A] = F2, e[A + 1] = F2, e[A + 2] = F2, e[A + 3] = 255;
|
|
9269
9668
|
}
|
|
9270
9669
|
}
|
|
9271
|
-
function q2(e,
|
|
9670
|
+
function q2(e, n3, a2, t) {
|
|
9272
9671
|
let r = a2 * t;
|
|
9273
9672
|
for (let o2 = 0; o2 < r; o2++) {
|
|
9274
|
-
let
|
|
9275
|
-
|
|
9673
|
+
let s = o2 * 4, c3 = e[s], m3 = e[s + 1], f2 = e[s + 2];
|
|
9674
|
+
n3[o2] = 0.298936 * c3 + 0.587043 * m3 + 0.114021 * f2;
|
|
9276
9675
|
}
|
|
9277
9676
|
}
|
|
9278
|
-
function S(e,
|
|
9279
|
-
let t = new Float32Array(
|
|
9280
|
-
for (let r = 1; r < a2 - 1; r++) for (let o2 = 1; o2 <
|
|
9281
|
-
let
|
|
9282
|
-
t[
|
|
9677
|
+
function S(e, n3, a2) {
|
|
9678
|
+
let t = new Float32Array(n3 * a2);
|
|
9679
|
+
for (let r = 1; r < a2 - 1; r++) for (let o2 = 1; o2 < n3 - 1; o2++) {
|
|
9680
|
+
let s = r * n3 + o2, c3 = e[(r - 1) * n3 + (o2 - 1)], m3 = e[(r - 1) * n3 + o2], f2 = e[(r - 1) * n3 + (o2 + 1)], l2 = e[r * n3 + (o2 - 1)], u = e[r * n3 + (o2 + 1)], b = e[(r + 1) * n3 + (o2 - 1)], x = e[(r + 1) * n3 + o2], F2 = e[(r + 1) * n3 + (o2 + 1)], A = (c3 + l2 + b - f2 - u - F2) / 3, g2 = (c3 + m3 + f2 - b - x - F2) / 3;
|
|
9681
|
+
t[s] = Math.sqrt(A * A + g2 * g2);
|
|
9283
9682
|
}
|
|
9284
9683
|
return t;
|
|
9285
9684
|
}
|
|
9286
|
-
function U(e,
|
|
9685
|
+
function U(e, n3, a2, t, r) {
|
|
9287
9686
|
let o2 = [];
|
|
9288
|
-
for (let
|
|
9289
|
-
let
|
|
9687
|
+
for (let s = 1; s < r - 1; s++) for (let c3 = 1; c3 < t - 1; c3++) {
|
|
9688
|
+
let m3 = s * t + c3, f2 = e[m3], l2 = n3[m3], u = 2 * f2 * l2 + a2, b = f2 * f2 + l2 * l2 + a2;
|
|
9290
9689
|
o2.push(u / b);
|
|
9291
9690
|
}
|
|
9292
9691
|
return new Float32Array(o2);
|
|
9293
9692
|
}
|
|
9294
9693
|
function W(e) {
|
|
9295
|
-
let
|
|
9296
|
-
if (
|
|
9694
|
+
let n3 = e.length;
|
|
9695
|
+
if (n3 === 0) return 0;
|
|
9297
9696
|
let a2 = 0;
|
|
9298
|
-
for (let o2 = 0; o2 <
|
|
9299
|
-
let t = a2 /
|
|
9300
|
-
for (let o2 = 0; o2 <
|
|
9301
|
-
let
|
|
9302
|
-
r +=
|
|
9697
|
+
for (let o2 = 0; o2 < n3; o2++) a2 += e[o2];
|
|
9698
|
+
let t = a2 / n3, r = 0;
|
|
9699
|
+
for (let o2 = 0; o2 < n3; o2++) {
|
|
9700
|
+
let s = e[o2] - t;
|
|
9701
|
+
r += s * s;
|
|
9303
9702
|
}
|
|
9304
|
-
return r /=
|
|
9703
|
+
return r /= n3, Math.sqrt(r);
|
|
9305
9704
|
}
|
|
9306
9705
|
var C;
|
|
9307
|
-
var
|
|
9706
|
+
var init_dist5 = __esm({
|
|
9308
9707
|
"../gmsd/dist/index.mjs"() {
|
|
9309
9708
|
"use strict";
|
|
9310
9709
|
C = D;
|
|
@@ -9328,7 +9727,7 @@ Options:
|
|
|
9328
9727
|
-o, --output <path> Output path for GMS similarity map (grayscale visualization)
|
|
9329
9728
|
--downsample <0|1> Downsample factor: 0=full-res, 1=2x downsample (default: 0)
|
|
9330
9729
|
--gmsd-c <num> Stability constant for GMSD (default: 170)
|
|
9331
|
-
--
|
|
9730
|
+
--codec <name> Specify codec to use (pngjs, sharp, jsquash-png)
|
|
9332
9731
|
-h, --help Show this help message
|
|
9333
9732
|
|
|
9334
9733
|
Examples:
|
|
@@ -9352,15 +9751,15 @@ async function main3() {
|
|
|
9352
9751
|
const image1 = args[0];
|
|
9353
9752
|
const image2 = args[1];
|
|
9354
9753
|
const options = {};
|
|
9355
|
-
for (let
|
|
9356
|
-
const arg = args[
|
|
9357
|
-
const nextArg = args[
|
|
9754
|
+
for (let i3 = 2; i3 < args.length; i3++) {
|
|
9755
|
+
const arg = args[i3];
|
|
9756
|
+
const nextArg = args[i3 + 1];
|
|
9358
9757
|
switch (arg) {
|
|
9359
9758
|
case "-o":
|
|
9360
9759
|
case "--output":
|
|
9361
9760
|
if (nextArg) {
|
|
9362
9761
|
options.outputPath = nextArg;
|
|
9363
|
-
|
|
9762
|
+
i3++;
|
|
9364
9763
|
}
|
|
9365
9764
|
break;
|
|
9366
9765
|
case "--downsample":
|
|
@@ -9370,7 +9769,7 @@ async function main3() {
|
|
|
9370
9769
|
throw new Error(`Invalid downsample: ${nextArg}. Must be 0 or 1`);
|
|
9371
9770
|
}
|
|
9372
9771
|
options.downsample = downsample;
|
|
9373
|
-
|
|
9772
|
+
i3++;
|
|
9374
9773
|
}
|
|
9375
9774
|
break;
|
|
9376
9775
|
case "--gmsd-c":
|
|
@@ -9382,13 +9781,13 @@ async function main3() {
|
|
|
9382
9781
|
);
|
|
9383
9782
|
}
|
|
9384
9783
|
options.gmsdC = gmsdC;
|
|
9385
|
-
|
|
9784
|
+
i3++;
|
|
9386
9785
|
}
|
|
9387
9786
|
break;
|
|
9388
|
-
case "--
|
|
9787
|
+
case "--codec":
|
|
9389
9788
|
if (nextArg) {
|
|
9390
|
-
options.
|
|
9391
|
-
|
|
9789
|
+
options.codec = nextArg;
|
|
9790
|
+
i3++;
|
|
9392
9791
|
}
|
|
9393
9792
|
break;
|
|
9394
9793
|
default:
|
|
@@ -9397,12 +9796,10 @@ async function main3() {
|
|
|
9397
9796
|
process.exit(1);
|
|
9398
9797
|
}
|
|
9399
9798
|
}
|
|
9400
|
-
const
|
|
9401
|
-
options.transformer
|
|
9402
|
-
);
|
|
9799
|
+
const codec = await getCodec2(options.codec);
|
|
9403
9800
|
const [img1, img2] = await Promise.all([
|
|
9404
|
-
|
|
9405
|
-
|
|
9801
|
+
codec.read(image1),
|
|
9802
|
+
codec.read(image2)
|
|
9406
9803
|
]);
|
|
9407
9804
|
if (img1.width !== img2.width || img1.height !== img2.height) {
|
|
9408
9805
|
throw new Error(
|
|
@@ -9428,7 +9825,7 @@ async function main3() {
|
|
|
9428
9825
|
);
|
|
9429
9826
|
const duration = performance.now() - startTime;
|
|
9430
9827
|
if (options.outputPath && outputData) {
|
|
9431
|
-
await
|
|
9828
|
+
await codec.write(
|
|
9432
9829
|
{
|
|
9433
9830
|
data: outputData,
|
|
9434
9831
|
width: img1.width,
|
|
@@ -9466,21 +9863,25 @@ async function main3() {
|
|
|
9466
9863
|
process.exit(1);
|
|
9467
9864
|
}
|
|
9468
9865
|
}
|
|
9469
|
-
var
|
|
9866
|
+
var getCodec2;
|
|
9470
9867
|
var init_gmsd = __esm({
|
|
9471
9868
|
"src/commands/gmsd.ts"() {
|
|
9472
9869
|
"use strict";
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
if (!
|
|
9476
|
-
const { default:
|
|
9477
|
-
return
|
|
9870
|
+
init_dist5();
|
|
9871
|
+
getCodec2 = async (codec) => {
|
|
9872
|
+
if (!codec || codec === "pngjs") {
|
|
9873
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
9874
|
+
return c3;
|
|
9875
|
+
}
|
|
9876
|
+
if (codec === "sharp") {
|
|
9877
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist3(), dist_exports2));
|
|
9878
|
+
return c3;
|
|
9478
9879
|
}
|
|
9479
|
-
if (
|
|
9480
|
-
const { default:
|
|
9481
|
-
return
|
|
9880
|
+
if (codec === "jsquash-png") {
|
|
9881
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist4(), dist_exports3));
|
|
9882
|
+
return c3;
|
|
9482
9883
|
}
|
|
9483
|
-
throw new Error(`Unknown
|
|
9884
|
+
throw new Error(`Unknown codec: ${codec}`);
|
|
9484
9885
|
};
|
|
9485
9886
|
if (typeof require !== "undefined" && require.main === module) {
|
|
9486
9887
|
main3();
|
|
@@ -9489,130 +9890,130 @@ var init_gmsd = __esm({
|
|
|
9489
9890
|
});
|
|
9490
9891
|
|
|
9491
9892
|
// ../ssim/dist/ssim.mjs
|
|
9492
|
-
function C2(f2, M,
|
|
9493
|
-
let r = new Float32Array(M *
|
|
9893
|
+
function C2(f2, M, l2) {
|
|
9894
|
+
let r = new Float32Array(M * l2), n3 = 0;
|
|
9494
9895
|
for (let u = 0; u < f2.length; u += 4) {
|
|
9495
9896
|
let e = f2[u], A = f2[u + 1], a2 = f2[u + 2];
|
|
9496
|
-
r[
|
|
9897
|
+
r[n3++] = 0.298936 * e + 0.587043 * A + 0.114021 * a2;
|
|
9497
9898
|
}
|
|
9498
9899
|
return r;
|
|
9499
9900
|
}
|
|
9500
|
-
function N2(f2, M,
|
|
9501
|
-
let { windowSize: e = 11, k1: A = 0.01, k2: a2 = 0.03, L:
|
|
9502
|
-
if (
|
|
9503
|
-
let y = Q(
|
|
9504
|
-
|
|
9505
|
-
}
|
|
9506
|
-
let x = P2(e, 1.5), b = (A *
|
|
9507
|
-
S2(
|
|
9508
|
-
let V3 =
|
|
9901
|
+
function N2(f2, M, l2, r, n3, u = {}) {
|
|
9902
|
+
let { windowSize: e = 11, k1: A = 0.01, k2: a2 = 0.03, L: i3 = 255 } = u, c3 = C2(f2, r, n3), s = C2(M, r, n3), o2 = r, t = n3, m3 = Math.max(1, Math.round(Math.min(r, n3) / 256));
|
|
9903
|
+
if (m3 > 1) {
|
|
9904
|
+
let y = Q(c3, s, o2, t, m3);
|
|
9905
|
+
c3 = y.img1, s = y.img2, o2 = y.width, t = y.height;
|
|
9906
|
+
}
|
|
9907
|
+
let x = P2(e, 1.5), b = (A * i3) ** 2, B = (a2 * i3) ** 2, R = o2 - e + 1, T = t - e + 1, g2 = R * T, v = new Float32Array(g2), O2 = new Float32Array(g2), G = new Float32Array(g2), H3 = new Float32Array(g2), I2 = new Float32Array(g2), U3 = new Float32Array(o2 * t);
|
|
9908
|
+
S2(c3, v, U3, o2, t, x, e), S2(s, O2, U3, o2, t, x, e);
|
|
9909
|
+
let V3 = c3.length;
|
|
9509
9910
|
for (let y = 0; y < V3; y++) {
|
|
9510
|
-
let
|
|
9511
|
-
U3[y] =
|
|
9911
|
+
let p3 = c3[y], d2 = s[y];
|
|
9912
|
+
U3[y] = p3 * d2, c3[y] = p3 * p3, s[y] = d2 * d2;
|
|
9512
9913
|
}
|
|
9513
9914
|
let q4 = new Float32Array(o2 * t);
|
|
9514
|
-
S2(
|
|
9915
|
+
S2(c3, G, q4, o2, t, x, e), S2(s, H3, q4, o2, t, x, e), S2(U3, I2, q4, o2, t, x, e);
|
|
9515
9916
|
let w = new Float32Array(v.length);
|
|
9516
9917
|
for (let y = 0; y < v.length; y++) {
|
|
9517
|
-
let
|
|
9918
|
+
let p3 = v[y], d2 = O2[y], W2 = p3 * p3, X2 = d2 * d2, Y = p3 * d2, $ = G[y] - W2, K2 = H3[y] - X2, _2 = I2[y] - Y, j3 = (2 * Y + b) * (2 * _2 + B), J = (W2 + X2 + b) * ($ + K2 + B);
|
|
9518
9919
|
w[y] = j3 / J;
|
|
9519
9920
|
}
|
|
9520
|
-
if (
|
|
9521
|
-
let y = o2 - e + 1,
|
|
9522
|
-
Z(
|
|
9921
|
+
if (l2) {
|
|
9922
|
+
let y = o2 - e + 1, p3 = t - e + 1;
|
|
9923
|
+
Z(l2, w, y, p3, r, n3);
|
|
9523
9924
|
}
|
|
9524
9925
|
let L3 = 0;
|
|
9525
9926
|
for (let y = 0; y < w.length; y++) L3 += w[y];
|
|
9526
9927
|
return L3 / w.length;
|
|
9527
9928
|
}
|
|
9528
9929
|
function P2(f2, M) {
|
|
9529
|
-
let
|
|
9930
|
+
let l2 = `${f2}_${M}`, r = D2.get(l2);
|
|
9530
9931
|
if (r) return r;
|
|
9531
|
-
let
|
|
9932
|
+
let n3 = new Float32Array(f2), u = (f2 - 1) / 2, e = 2 * M * M, A = 0;
|
|
9532
9933
|
for (let a2 = 0; a2 < f2; a2++) {
|
|
9533
|
-
let
|
|
9534
|
-
|
|
9934
|
+
let i3 = a2 - u, c3 = Math.exp(-(i3 * i3) / e);
|
|
9935
|
+
n3[a2] = c3, A += c3;
|
|
9535
9936
|
}
|
|
9536
|
-
for (let a2 = 0; a2 < f2; a2++)
|
|
9537
|
-
return D2.set(
|
|
9937
|
+
for (let a2 = 0; a2 < f2; a2++) n3[a2] /= A;
|
|
9938
|
+
return D2.set(l2, n3), n3;
|
|
9538
9939
|
}
|
|
9539
|
-
function S2(f2, M,
|
|
9940
|
+
function S2(f2, M, l2, r, n3, u, e) {
|
|
9540
9941
|
let A = Math.floor(e / 2);
|
|
9541
|
-
for (let
|
|
9542
|
-
let o2 =
|
|
9942
|
+
for (let s = 0; s < n3; s++) {
|
|
9943
|
+
let o2 = s * r;
|
|
9543
9944
|
for (let t = 0; t < A; t++) {
|
|
9544
|
-
let
|
|
9945
|
+
let m3 = 0;
|
|
9545
9946
|
for (let F2 = 0; F2 < e; F2++) {
|
|
9546
9947
|
let x = t + F2 - A, b = Math.max(0, Math.min(r - 1, x));
|
|
9547
|
-
|
|
9948
|
+
m3 += f2[o2 + b] * u[F2];
|
|
9548
9949
|
}
|
|
9549
|
-
|
|
9950
|
+
l2[o2 + t] = m3;
|
|
9550
9951
|
}
|
|
9551
9952
|
for (let t = A; t < r - A; t++) {
|
|
9552
|
-
let
|
|
9553
|
-
for (let x = 0; x < e; x++)
|
|
9554
|
-
|
|
9953
|
+
let m3 = 0, F2 = o2 + t - A;
|
|
9954
|
+
for (let x = 0; x < e; x++) m3 += f2[F2 + x] * u[x];
|
|
9955
|
+
l2[o2 + t] = m3;
|
|
9555
9956
|
}
|
|
9556
9957
|
for (let t = r - A; t < r; t++) {
|
|
9557
|
-
let
|
|
9958
|
+
let m3 = 0;
|
|
9558
9959
|
for (let F2 = 0; F2 < e; F2++) {
|
|
9559
9960
|
let x = t + F2 - A, b = Math.max(0, Math.min(r - 1, x));
|
|
9560
|
-
|
|
9961
|
+
m3 += f2[o2 + b] * u[F2];
|
|
9561
9962
|
}
|
|
9562
|
-
|
|
9963
|
+
l2[o2 + t] = m3;
|
|
9563
9964
|
}
|
|
9564
9965
|
}
|
|
9565
|
-
let a2 = r - e + 1,
|
|
9566
|
-
for (let
|
|
9567
|
-
let t = 0,
|
|
9966
|
+
let a2 = r - e + 1, i3 = n3 - e + 1, c3 = 0;
|
|
9967
|
+
for (let s = 0; s < i3; s++) for (let o2 = 0; o2 < a2; o2++) {
|
|
9968
|
+
let t = 0, m3 = o2 + A;
|
|
9568
9969
|
for (let F2 = 0; F2 < e; F2++) {
|
|
9569
|
-
let x =
|
|
9570
|
-
t +=
|
|
9970
|
+
let x = s + F2;
|
|
9971
|
+
t += l2[x * r + m3] * u[F2];
|
|
9571
9972
|
}
|
|
9572
|
-
M[
|
|
9973
|
+
M[c3++] = t;
|
|
9573
9974
|
}
|
|
9574
9975
|
}
|
|
9575
|
-
function Q(f2, M,
|
|
9576
|
-
let u = new Float32Array(
|
|
9577
|
-
for (let
|
|
9578
|
-
let A = new Float32Array(
|
|
9579
|
-
E(f2, a2, A,
|
|
9580
|
-
let
|
|
9581
|
-
E(M,
|
|
9582
|
-
let
|
|
9583
|
-
for (let
|
|
9584
|
-
let F2 =
|
|
9585
|
-
for (let b = 0; b <
|
|
9586
|
-
}
|
|
9587
|
-
return { img1: o2, img2: t, width:
|
|
9976
|
+
function Q(f2, M, l2, r, n3) {
|
|
9977
|
+
let u = new Float32Array(n3), e = 1 / n3;
|
|
9978
|
+
for (let m3 = 0; m3 < n3; m3++) u[m3] = e;
|
|
9979
|
+
let A = new Float32Array(l2 * r), a2 = new Float32Array(l2 * r);
|
|
9980
|
+
E(f2, a2, A, l2, r, u, n3);
|
|
9981
|
+
let i3 = new Float32Array(l2 * r);
|
|
9982
|
+
E(M, i3, A, l2, r, u, n3);
|
|
9983
|
+
let c3 = Math.floor(l2 / n3), s = Math.floor(r / n3), o2 = new Float32Array(c3 * s), t = new Float32Array(c3 * s);
|
|
9984
|
+
for (let m3 = 0; m3 < s; m3++) {
|
|
9985
|
+
let F2 = m3 * n3 * l2, x = m3 * c3;
|
|
9986
|
+
for (let b = 0; b < c3; b++) o2[x + b] = a2[F2 + b * n3], t[x + b] = i3[F2 + b * n3];
|
|
9987
|
+
}
|
|
9988
|
+
return { img1: o2, img2: t, width: c3, height: s };
|
|
9588
9989
|
}
|
|
9589
|
-
function E(f2, M,
|
|
9990
|
+
function E(f2, M, l2, r, n3, u, e) {
|
|
9590
9991
|
let A = Math.floor(e / 2);
|
|
9591
|
-
for (let a2 = 0; a2 <
|
|
9592
|
-
let
|
|
9593
|
-
for (let
|
|
9594
|
-
let
|
|
9992
|
+
for (let a2 = 0; a2 < n3; a2++) {
|
|
9993
|
+
let i3 = a2 * r;
|
|
9994
|
+
for (let c3 = 0; c3 < r; c3++) {
|
|
9995
|
+
let s = 0;
|
|
9595
9996
|
for (let o2 = 0; o2 < e; o2++) {
|
|
9596
|
-
let t =
|
|
9597
|
-
t < 0 ? t = -t : t >= r && (t = 2 * r - t - 2), t = Math.max(0, Math.min(r - 1, t)),
|
|
9997
|
+
let t = c3 + o2 - A;
|
|
9998
|
+
t < 0 ? t = -t : t >= r && (t = 2 * r - t - 2), t = Math.max(0, Math.min(r - 1, t)), s += f2[i3 + t] * u[o2];
|
|
9598
9999
|
}
|
|
9599
|
-
|
|
10000
|
+
l2[i3 + c3] = s;
|
|
9600
10001
|
}
|
|
9601
10002
|
}
|
|
9602
|
-
for (let a2 = 0; a2 <
|
|
9603
|
-
let
|
|
9604
|
-
for (let
|
|
9605
|
-
let o2 = a2 +
|
|
9606
|
-
o2 < 0 ? o2 = -o2 : o2 >=
|
|
10003
|
+
for (let a2 = 0; a2 < n3; a2++) for (let i3 = 0; i3 < r; i3++) {
|
|
10004
|
+
let c3 = 0;
|
|
10005
|
+
for (let s = 0; s < e; s++) {
|
|
10006
|
+
let o2 = a2 + s - A;
|
|
10007
|
+
o2 < 0 ? o2 = -o2 : o2 >= n3 && (o2 = 2 * n3 - o2 - 2), o2 = Math.max(0, Math.min(n3 - 1, o2)), c3 += l2[o2 * r + i3] * u[s];
|
|
9607
10008
|
}
|
|
9608
|
-
M[a2 * r +
|
|
10009
|
+
M[a2 * r + i3] = c3;
|
|
9609
10010
|
}
|
|
9610
10011
|
}
|
|
9611
|
-
function Z(f2, M,
|
|
9612
|
-
let e =
|
|
9613
|
-
for (let a2 = 0; a2 < u; a2++) for (let
|
|
9614
|
-
let
|
|
9615
|
-
f2[
|
|
10012
|
+
function Z(f2, M, l2, r, n3, u) {
|
|
10013
|
+
let e = n3 / l2, A = u / r;
|
|
10014
|
+
for (let a2 = 0; a2 < u; a2++) for (let i3 = 0; i3 < n3; i3++) {
|
|
10015
|
+
let c3 = Math.min(Math.floor(i3 / e), l2 - 1), s = Math.min(Math.floor(a2 / A), r - 1), o2 = M[s * l2 + c3], t = Math.floor(Math.max(0, Math.min(1, o2)) * 255), m3 = (a2 * n3 + i3) * 4;
|
|
10016
|
+
f2[m3] = t, f2[m3 + 1] = t, f2[m3 + 2] = t, f2[m3 + 3] = 255;
|
|
9616
10017
|
}
|
|
9617
10018
|
}
|
|
9618
10019
|
var D2, z;
|
|
@@ -9639,7 +10040,7 @@ Arguments:
|
|
|
9639
10040
|
|
|
9640
10041
|
Options:
|
|
9641
10042
|
-o, --output <path> Output path for SSIM map visualization
|
|
9642
|
-
--
|
|
10043
|
+
--codec <name> Specify codec to use (pngjs, sharp, jsquash-png)
|
|
9643
10044
|
-h, --help Show this help message
|
|
9644
10045
|
|
|
9645
10046
|
Examples:
|
|
@@ -9662,21 +10063,21 @@ async function main4() {
|
|
|
9662
10063
|
const image1 = args[0];
|
|
9663
10064
|
const image2 = args[1];
|
|
9664
10065
|
const options = {};
|
|
9665
|
-
for (let
|
|
9666
|
-
const arg = args[
|
|
9667
|
-
const nextArg = args[
|
|
10066
|
+
for (let i3 = 2; i3 < args.length; i3++) {
|
|
10067
|
+
const arg = args[i3];
|
|
10068
|
+
const nextArg = args[i3 + 1];
|
|
9668
10069
|
switch (arg) {
|
|
9669
10070
|
case "-o":
|
|
9670
10071
|
case "--output":
|
|
9671
10072
|
if (nextArg) {
|
|
9672
10073
|
options.outputPath = nextArg;
|
|
9673
|
-
|
|
10074
|
+
i3++;
|
|
9674
10075
|
}
|
|
9675
10076
|
break;
|
|
9676
|
-
case "--
|
|
10077
|
+
case "--codec":
|
|
9677
10078
|
if (nextArg) {
|
|
9678
|
-
options.
|
|
9679
|
-
|
|
10079
|
+
options.codec = nextArg;
|
|
10080
|
+
i3++;
|
|
9680
10081
|
}
|
|
9681
10082
|
break;
|
|
9682
10083
|
default:
|
|
@@ -9685,10 +10086,10 @@ async function main4() {
|
|
|
9685
10086
|
process.exit(1);
|
|
9686
10087
|
}
|
|
9687
10088
|
}
|
|
9688
|
-
const
|
|
10089
|
+
const codec = await getCodec3(options.codec);
|
|
9689
10090
|
const [img1, img2] = await Promise.all([
|
|
9690
|
-
|
|
9691
|
-
|
|
10091
|
+
codec.read(image1),
|
|
10092
|
+
codec.read(image2)
|
|
9692
10093
|
]);
|
|
9693
10094
|
if (img1.width !== img2.width || img1.height !== img2.height) {
|
|
9694
10095
|
throw new Error(
|
|
@@ -9710,7 +10111,7 @@ async function main4() {
|
|
|
9710
10111
|
);
|
|
9711
10112
|
const duration = performance.now() - startTime;
|
|
9712
10113
|
if (options.outputPath && outputData) {
|
|
9713
|
-
await
|
|
10114
|
+
await codec.write(
|
|
9714
10115
|
{
|
|
9715
10116
|
data: outputData,
|
|
9716
10117
|
width: img1.width,
|
|
@@ -9748,21 +10149,25 @@ async function main4() {
|
|
|
9748
10149
|
process.exit(1);
|
|
9749
10150
|
}
|
|
9750
10151
|
}
|
|
9751
|
-
var
|
|
10152
|
+
var getCodec3;
|
|
9752
10153
|
var init_ssim2 = __esm({
|
|
9753
10154
|
"src/commands/ssim.ts"() {
|
|
9754
10155
|
"use strict";
|
|
9755
10156
|
init_ssim();
|
|
9756
|
-
|
|
9757
|
-
if (!
|
|
9758
|
-
const { default:
|
|
9759
|
-
return
|
|
10157
|
+
getCodec3 = async (codec) => {
|
|
10158
|
+
if (!codec || codec === "pngjs") {
|
|
10159
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
10160
|
+
return c3;
|
|
10161
|
+
}
|
|
10162
|
+
if (codec === "sharp") {
|
|
10163
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist3(), dist_exports2));
|
|
10164
|
+
return c3;
|
|
9760
10165
|
}
|
|
9761
|
-
if (
|
|
9762
|
-
const { default:
|
|
9763
|
-
return
|
|
10166
|
+
if (codec === "jsquash-png") {
|
|
10167
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist4(), dist_exports3));
|
|
10168
|
+
return c3;
|
|
9764
10169
|
}
|
|
9765
|
-
throw new Error(`Unknown
|
|
10170
|
+
throw new Error(`Unknown codec: ${codec}`);
|
|
9766
10171
|
};
|
|
9767
10172
|
if (typeof require !== "undefined" && require.main === module) {
|
|
9768
10173
|
main4();
|
|
@@ -9771,99 +10176,99 @@ var init_ssim2 = __esm({
|
|
|
9771
10176
|
});
|
|
9772
10177
|
|
|
9773
10178
|
// ../ssim/dist/msssim.mjs
|
|
9774
|
-
function I(a2, f2,
|
|
9775
|
-
let r = new Float32Array(f2 *
|
|
10179
|
+
function I(a2, f2, n3) {
|
|
10180
|
+
let r = new Float32Array(f2 * n3), t = 0;
|
|
9776
10181
|
for (let y = 0; y < a2.length; y += 4) {
|
|
9777
|
-
let
|
|
9778
|
-
r[t++] = 0.298936 *
|
|
10182
|
+
let m3 = a2[y], p3 = a2[y + 1], s = a2[y + 2];
|
|
10183
|
+
r[t++] = 0.298936 * m3 + 0.587043 * p3 + 0.114021 * s;
|
|
9779
10184
|
}
|
|
9780
10185
|
return r;
|
|
9781
10186
|
}
|
|
9782
|
-
function K(a2, f2,
|
|
9783
|
-
let { windowSize:
|
|
9784
|
-
for (let
|
|
9785
|
-
let b = L2(
|
|
9786
|
-
if (d2.push(b.mssim), B.push(b.mcs),
|
|
9787
|
-
let M = E2(
|
|
9788
|
-
|
|
9789
|
-
}
|
|
9790
|
-
}
|
|
9791
|
-
if (
|
|
9792
|
-
let
|
|
9793
|
-
for (let b = 0; b < e - 1; b++)
|
|
9794
|
-
return
|
|
10187
|
+
function K(a2, f2, n3, r, t, y = {}) {
|
|
10188
|
+
let { windowSize: m3 = 11, k1: p3 = 0.01, k2: s = 0.03, bitDepth: c3 = 8, level: e = 5, weight: u = [0.0448, 0.2856, 0.3001, 0.2363, 0.1333], method: o2 = "product" } = y, l2 = I(a2, r, t), A = I(f2, r, t), x = r, S3 = t, d2 = [], B = [], C3;
|
|
10189
|
+
for (let i3 = 0; i3 < e; i3++) {
|
|
10190
|
+
let b = L2(l2, A, x, S3, m3, p3, s, c3);
|
|
10191
|
+
if (d2.push(b.mssim), B.push(b.mcs), i3 === e - 1 && n3 && (C3 = b.ssimMap), i3 < e - 1) {
|
|
10192
|
+
let M = E2(l2, A, x, S3);
|
|
10193
|
+
l2 = M.img1, A = M.img2, x = M.width, S3 = M.height;
|
|
10194
|
+
}
|
|
10195
|
+
}
|
|
10196
|
+
if (n3 && C3 && H2(n3, C3, x, S3, r, t), o2 === "product") {
|
|
10197
|
+
let i3 = 1;
|
|
10198
|
+
for (let b = 0; b < e - 1; b++) i3 *= B[b] ** u[b];
|
|
10199
|
+
return i3 *= d2[e - 1] ** u[e - 1], i3;
|
|
9795
10200
|
} else {
|
|
9796
|
-
let
|
|
9797
|
-
for (let M = 0; M < e - 1; M++) b += B[M] *
|
|
9798
|
-
return b += d2[e - 1] *
|
|
10201
|
+
let i3 = u.map((M) => M / u.reduce((D3, G) => D3 + G, 0)), b = 0;
|
|
10202
|
+
for (let M = 0; M < e - 1; M++) b += B[M] * i3[M];
|
|
10203
|
+
return b += d2[e - 1] * i3[e - 1], b;
|
|
9799
10204
|
}
|
|
9800
10205
|
}
|
|
9801
|
-
function L2(a2, f2,
|
|
9802
|
-
let
|
|
9803
|
-
q3(a2, o2, d2,
|
|
9804
|
-
let C3 = new Float32Array(
|
|
10206
|
+
function L2(a2, f2, n3, r, t, y, m3, p3) {
|
|
10207
|
+
let s = 2 ** p3 - 1, c3 = (y * s) ** 2, e = (m3 * s) ** 2, u = V2(t, 1.5), o2 = new Float32Array(n3 * r), l2 = new Float32Array(n3 * r), A = new Float32Array(n3 * r), x = new Float32Array(n3 * r), S3 = new Float32Array(n3 * r), d2 = new Float32Array(n3 * r), B = new Float32Array(n3 * r);
|
|
10208
|
+
q3(a2, o2, d2, n3, r, u, t), q3(f2, l2, d2, n3, r, u, t);
|
|
10209
|
+
let C3 = new Float32Array(n3 * r), i3 = new Float32Array(n3 * r), b = new Float32Array(n3 * r), M = a2.length;
|
|
9805
10210
|
for (let F2 = 0; F2 < M; F2++) {
|
|
9806
10211
|
let v = a2[F2], U3 = f2[F2];
|
|
9807
|
-
C3[F2] = v * v,
|
|
10212
|
+
C3[F2] = v * v, i3[F2] = U3 * U3, b[F2] = v * U3;
|
|
9808
10213
|
}
|
|
9809
|
-
q3(C3, A, d2,
|
|
10214
|
+
q3(C3, A, d2, n3, r, u, t), q3(i3, x, d2, n3, r, u, t), q3(b, S3, B, n3, r, u, t);
|
|
9810
10215
|
let D3 = 0, G = 0, O2 = new Float32Array(o2.length);
|
|
9811
10216
|
for (let F2 = 0; F2 < o2.length; F2++) {
|
|
9812
|
-
let v = o2[F2], U3 =
|
|
10217
|
+
let v = o2[F2], U3 = l2[F2], g2 = v * v, w = U3 * U3, R = v * U3, Y = A[F2] - g2, _2 = x[F2] - w, $ = S3[F2] - R, k = (2 * R + c3) / (g2 + w + c3), T = (2 * $ + e) / (Y + _2 + e), W2 = k * T;
|
|
9813
10218
|
O2[F2] = W2, D3 += W2, G += T;
|
|
9814
10219
|
}
|
|
9815
10220
|
return { mssim: D3 / o2.length, mcs: G / o2.length, ssimMap: O2 };
|
|
9816
10221
|
}
|
|
9817
10222
|
function V2(a2, f2) {
|
|
9818
|
-
let
|
|
9819
|
-
return r || (r = j2(a2, f2), X.set(
|
|
10223
|
+
let n3 = `${a2}_${f2}`, r = X.get(n3);
|
|
10224
|
+
return r || (r = j2(a2, f2), X.set(n3, r)), r;
|
|
9820
10225
|
}
|
|
9821
10226
|
function j2(a2, f2) {
|
|
9822
|
-
let
|
|
9823
|
-
for (let
|
|
9824
|
-
let
|
|
9825
|
-
|
|
10227
|
+
let n3 = new Float32Array(a2), r = (a2 - 1) / 2, t = 2 * f2 * f2, y = 0;
|
|
10228
|
+
for (let m3 = 0; m3 < a2; m3++) {
|
|
10229
|
+
let p3 = m3 - r, s = Math.exp(-(p3 * p3) / t);
|
|
10230
|
+
n3[m3] = s, y += s;
|
|
9826
10231
|
}
|
|
9827
|
-
for (let
|
|
9828
|
-
return
|
|
10232
|
+
for (let m3 = 0; m3 < a2; m3++) n3[m3] /= y;
|
|
10233
|
+
return n3;
|
|
9829
10234
|
}
|
|
9830
|
-
function q3(a2, f2,
|
|
9831
|
-
let
|
|
9832
|
-
for (let
|
|
9833
|
-
let
|
|
10235
|
+
function q3(a2, f2, n3, r, t, y, m3) {
|
|
10236
|
+
let p3 = Math.floor(m3 / 2);
|
|
10237
|
+
for (let s = 0; s < t; s++) {
|
|
10238
|
+
let c3 = s * r;
|
|
9834
10239
|
for (let e = 0; e < r; e++) {
|
|
9835
10240
|
let u = 0;
|
|
9836
|
-
for (let o2 = 0; o2 <
|
|
9837
|
-
let
|
|
9838
|
-
|
|
10241
|
+
for (let o2 = 0; o2 < m3; o2++) {
|
|
10242
|
+
let l2 = e + o2 - p3;
|
|
10243
|
+
l2 < 0 ? l2 = -l2 : l2 >= r && (l2 = 2 * r - l2 - 2), l2 = Math.max(0, Math.min(r - 1, l2)), u += a2[c3 + l2] * y[o2];
|
|
9839
10244
|
}
|
|
9840
|
-
|
|
10245
|
+
n3[c3 + e] = u;
|
|
9841
10246
|
}
|
|
9842
10247
|
}
|
|
9843
|
-
for (let
|
|
10248
|
+
for (let s = 0; s < t; s++) for (let c3 = 0; c3 < r; c3++) {
|
|
9844
10249
|
let e = 0;
|
|
9845
|
-
for (let u = 0; u <
|
|
9846
|
-
let o2 =
|
|
9847
|
-
o2 < 0 ? o2 = -o2 : o2 >= t && (o2 = 2 * t - o2 - 2), o2 = Math.max(0, Math.min(t - 1, o2)), e +=
|
|
10250
|
+
for (let u = 0; u < m3; u++) {
|
|
10251
|
+
let o2 = s + u - p3;
|
|
10252
|
+
o2 < 0 ? o2 = -o2 : o2 >= t && (o2 = 2 * t - o2 - 2), o2 = Math.max(0, Math.min(t - 1, o2)), e += n3[o2 * r + c3] * y[u];
|
|
9848
10253
|
}
|
|
9849
|
-
f2[
|
|
10254
|
+
f2[s * r + c3] = e;
|
|
9850
10255
|
}
|
|
9851
10256
|
}
|
|
9852
|
-
function E2(a2, f2,
|
|
9853
|
-
let t = new Float32Array([0.5, 0.5]), y = new Float32Array(
|
|
9854
|
-
q3(a2, y,
|
|
9855
|
-
let
|
|
9856
|
-
for (let
|
|
9857
|
-
let x =
|
|
9858
|
-
u[S3] = y[x], o2[S3] =
|
|
9859
|
-
}
|
|
9860
|
-
return { img1: u, img2: o2, width:
|
|
10257
|
+
function E2(a2, f2, n3, r) {
|
|
10258
|
+
let t = new Float32Array([0.5, 0.5]), y = new Float32Array(n3 * r), m3 = new Float32Array(n3 * r), p3 = new Float32Array(n3 * r), s = new Float32Array(n3 * r);
|
|
10259
|
+
q3(a2, y, p3, n3, r, t, 2), q3(f2, m3, s, n3, r, t, 2);
|
|
10260
|
+
let c3 = Math.floor(n3 / 2), e = Math.floor(r / 2), u = new Float32Array(c3 * e), o2 = new Float32Array(c3 * e);
|
|
10261
|
+
for (let l2 = 0; l2 < e; l2++) for (let A = 0; A < c3; A++) {
|
|
10262
|
+
let x = l2 * 2 * n3 + A * 2, S3 = l2 * c3 + A;
|
|
10263
|
+
u[S3] = y[x], o2[S3] = m3[x];
|
|
10264
|
+
}
|
|
10265
|
+
return { img1: u, img2: o2, width: c3, height: e };
|
|
9861
10266
|
}
|
|
9862
|
-
function H2(a2, f2,
|
|
9863
|
-
let
|
|
9864
|
-
for (let
|
|
9865
|
-
let e = Math.min(Math.floor(
|
|
9866
|
-
a2[A] =
|
|
10267
|
+
function H2(a2, f2, n3, r, t, y) {
|
|
10268
|
+
let m3 = t / n3, p3 = y / r;
|
|
10269
|
+
for (let s = 0; s < y; s++) for (let c3 = 0; c3 < t; c3++) {
|
|
10270
|
+
let e = Math.min(Math.floor(c3 / m3), n3 - 1), u = Math.min(Math.floor(s / p3), r - 1), o2 = f2[u * n3 + e], l2 = Math.floor(Math.max(0, Math.min(1, o2)) * 255), A = (s * t + c3) * 4;
|
|
10271
|
+
a2[A] = l2, a2[A + 1] = l2, a2[A + 2] = l2, a2[A + 3] = 255;
|
|
9867
10272
|
}
|
|
9868
10273
|
}
|
|
9869
10274
|
var X, P3;
|
|
@@ -9890,7 +10295,7 @@ Arguments:
|
|
|
9890
10295
|
|
|
9891
10296
|
Options:
|
|
9892
10297
|
-o, --output <path> Output path for MS-SSIM map visualization
|
|
9893
|
-
--
|
|
10298
|
+
--codec <name> Specify codec to use (pngjs, sharp, jsquash-png)
|
|
9894
10299
|
-h, --help Show this help message
|
|
9895
10300
|
|
|
9896
10301
|
Examples:
|
|
@@ -9913,21 +10318,21 @@ async function main5() {
|
|
|
9913
10318
|
const image1 = args[0];
|
|
9914
10319
|
const image2 = args[1];
|
|
9915
10320
|
const options = {};
|
|
9916
|
-
for (let
|
|
9917
|
-
const arg = args[
|
|
9918
|
-
const nextArg = args[
|
|
10321
|
+
for (let i3 = 2; i3 < args.length; i3++) {
|
|
10322
|
+
const arg = args[i3];
|
|
10323
|
+
const nextArg = args[i3 + 1];
|
|
9919
10324
|
switch (arg) {
|
|
9920
10325
|
case "-o":
|
|
9921
10326
|
case "--output":
|
|
9922
10327
|
if (nextArg) {
|
|
9923
10328
|
options.outputPath = nextArg;
|
|
9924
|
-
|
|
10329
|
+
i3++;
|
|
9925
10330
|
}
|
|
9926
10331
|
break;
|
|
9927
|
-
case "--
|
|
10332
|
+
case "--codec":
|
|
9928
10333
|
if (nextArg) {
|
|
9929
|
-
options.
|
|
9930
|
-
|
|
10334
|
+
options.codec = nextArg;
|
|
10335
|
+
i3++;
|
|
9931
10336
|
}
|
|
9932
10337
|
break;
|
|
9933
10338
|
default:
|
|
@@ -9936,10 +10341,10 @@ async function main5() {
|
|
|
9936
10341
|
process.exit(1);
|
|
9937
10342
|
}
|
|
9938
10343
|
}
|
|
9939
|
-
const
|
|
10344
|
+
const codec = await getCodec4(options.codec);
|
|
9940
10345
|
const [img1, img2] = await Promise.all([
|
|
9941
|
-
|
|
9942
|
-
|
|
10346
|
+
codec.read(image1),
|
|
10347
|
+
codec.read(image2)
|
|
9943
10348
|
]);
|
|
9944
10349
|
if (img1.width !== img2.width || img1.height !== img2.height) {
|
|
9945
10350
|
throw new Error(
|
|
@@ -9961,7 +10366,7 @@ async function main5() {
|
|
|
9961
10366
|
);
|
|
9962
10367
|
const duration = performance.now() - startTime;
|
|
9963
10368
|
if (options.outputPath && outputData) {
|
|
9964
|
-
await
|
|
10369
|
+
await codec.write(
|
|
9965
10370
|
{
|
|
9966
10371
|
data: outputData,
|
|
9967
10372
|
width: img1.width,
|
|
@@ -9999,21 +10404,25 @@ async function main5() {
|
|
|
9999
10404
|
process.exit(1);
|
|
10000
10405
|
}
|
|
10001
10406
|
}
|
|
10002
|
-
var
|
|
10407
|
+
var getCodec4;
|
|
10003
10408
|
var init_msssim2 = __esm({
|
|
10004
10409
|
"src/commands/msssim.ts"() {
|
|
10005
10410
|
"use strict";
|
|
10006
10411
|
init_msssim();
|
|
10007
|
-
|
|
10008
|
-
if (!
|
|
10009
|
-
const { default:
|
|
10010
|
-
return
|
|
10412
|
+
getCodec4 = async (codec) => {
|
|
10413
|
+
if (!codec || codec === "pngjs") {
|
|
10414
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
10415
|
+
return c3;
|
|
10011
10416
|
}
|
|
10012
|
-
if (
|
|
10013
|
-
const { default:
|
|
10014
|
-
return
|
|
10417
|
+
if (codec === "sharp") {
|
|
10418
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist3(), dist_exports2));
|
|
10419
|
+
return c3;
|
|
10015
10420
|
}
|
|
10016
|
-
|
|
10421
|
+
if (codec === "jsquash-png") {
|
|
10422
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist4(), dist_exports3));
|
|
10423
|
+
return c3;
|
|
10424
|
+
}
|
|
10425
|
+
throw new Error(`Unknown codec: ${codec}`);
|
|
10017
10426
|
};
|
|
10018
10427
|
if (typeof require !== "undefined" && require.main === module) {
|
|
10019
10428
|
main5();
|
|
@@ -10022,62 +10431,62 @@ var init_msssim2 = __esm({
|
|
|
10022
10431
|
});
|
|
10023
10432
|
|
|
10024
10433
|
// ../ssim/dist/hitchhikers-ssim.mjs
|
|
10025
|
-
function
|
|
10026
|
-
let
|
|
10027
|
-
for (let
|
|
10028
|
-
let t = o2[
|
|
10029
|
-
|
|
10434
|
+
function p2(o2, a2, c3) {
|
|
10435
|
+
let n3 = new Float32Array(a2 * c3), r = 0;
|
|
10436
|
+
for (let s = 0; s < o2.length; s += 4) {
|
|
10437
|
+
let t = o2[s], e = o2[s + 1], u = o2[s + 2];
|
|
10438
|
+
n3[r++] = 0.298936 * t + 0.587043 * e + 0.114021 * u;
|
|
10030
10439
|
}
|
|
10031
|
-
return
|
|
10440
|
+
return n3;
|
|
10032
10441
|
}
|
|
10033
|
-
function
|
|
10034
|
-
let { windowSize: t = 11, windowStride: e = t, k1: u = 0.01, k2:
|
|
10035
|
-
for (let
|
|
10036
|
-
let
|
|
10037
|
-
P4[
|
|
10038
|
-
}
|
|
10039
|
-
let D3 = F(P4,
|
|
10040
|
-
for (let
|
|
10041
|
-
let
|
|
10442
|
+
function h3(o2, a2, c3, n3, r, s = {}) {
|
|
10443
|
+
let { windowSize: t = 11, windowStride: e = t, k1: u = 0.01, k2: i3 = 0.03, L: d2 = 255, covPooling: v = true } = s, g2 = p2(o2, n3, r), A = p2(a2, n3, r), y = (u * d2) ** 2, O2 = (i3 * d2) ** 2, Y = F(g2, n3, r), z2 = F(A, n3, r), P4 = new Float32Array(n3 * r), G = new Float32Array(n3 * r), H3 = new Float32Array(n3 * r);
|
|
10444
|
+
for (let l2 = 0; l2 < g2.length; l2++) {
|
|
10445
|
+
let m3 = g2[l2], f2 = A[l2];
|
|
10446
|
+
P4[l2] = m3 * m3, G[l2] = f2 * f2, H3[l2] = m3 * f2;
|
|
10447
|
+
}
|
|
10448
|
+
let D3 = F(P4, n3, r), V3 = F(G, n3, r), j3 = F(H3, n3, r), M = Math.floor((n3 - t) / e) + 1, I2 = Math.floor((r - t) / e) + 1, S3 = new Float32Array(M * I2), x = t * t, E3 = 0;
|
|
10449
|
+
for (let l2 = 0; l2 < I2; l2++) {
|
|
10450
|
+
let m3 = l2 * e, f2 = m3 + t;
|
|
10042
10451
|
for (let k = 0; k < M; k++) {
|
|
10043
|
-
let b = k * e, q4 = b + t, J = U2(Y, b,
|
|
10452
|
+
let b = k * e, q4 = b + t, J = U2(Y, b, m3, q4, f2, n3), K2 = U2(z2, b, m3, q4, f2, n3), N3 = U2(D3, b, m3, q4, f2, n3), Q2 = U2(V3, b, m3, q4, f2, n3), R = U2(j3, b, m3, q4, f2, n3), C3 = J / x, B = K2 / x, L3 = C3 * C3, T = B * B, X2 = C3 * B, W2 = N3 / x - L3, Z2 = Q2 / x - T, _2 = R / x - X2, $ = (2 * X2 + y) * (2 * _2 + O2), w = (L3 + T + y) * (W2 + Z2 + O2);
|
|
10044
10453
|
S3[E3++] = $ / w;
|
|
10045
10454
|
}
|
|
10046
10455
|
}
|
|
10047
|
-
if (
|
|
10456
|
+
if (c3 && on2(c3, S3, M, I2, n3, r), v) return nn2(S3);
|
|
10048
10457
|
{
|
|
10049
|
-
let
|
|
10050
|
-
for (let
|
|
10051
|
-
return
|
|
10458
|
+
let l2 = 0;
|
|
10459
|
+
for (let m3 = 0; m3 < S3.length; m3++) l2 += S3[m3];
|
|
10460
|
+
return l2 / S3.length;
|
|
10052
10461
|
}
|
|
10053
10462
|
}
|
|
10054
|
-
function F(o2, a2,
|
|
10055
|
-
let
|
|
10056
|
-
for (let t = 1; t <=
|
|
10057
|
-
let u = (t - 1) * a2 + (e - 1),
|
|
10058
|
-
|
|
10463
|
+
function F(o2, a2, c3) {
|
|
10464
|
+
let n3 = a2 + 1, r = c3 + 1, s = new Float64Array(n3 * r);
|
|
10465
|
+
for (let t = 1; t <= c3; t++) for (let e = 1; e <= a2; e++) {
|
|
10466
|
+
let u = (t - 1) * a2 + (e - 1), i3 = t * n3 + e;
|
|
10467
|
+
s[i3] = o2[u] + s[(t - 1) * n3 + e] + s[t * n3 + (e - 1)] - s[(t - 1) * n3 + (e - 1)];
|
|
10059
10468
|
}
|
|
10060
|
-
return
|
|
10469
|
+
return s;
|
|
10061
10470
|
}
|
|
10062
|
-
function U2(o2, a2,
|
|
10063
|
-
let t =
|
|
10064
|
-
return o2[r * t +
|
|
10471
|
+
function U2(o2, a2, c3, n3, r, s) {
|
|
10472
|
+
let t = s + 1;
|
|
10473
|
+
return o2[r * t + n3] - o2[c3 * t + n3] - o2[r * t + a2] + o2[c3 * t + a2];
|
|
10065
10474
|
}
|
|
10066
10475
|
function nn2(o2) {
|
|
10067
10476
|
let a2 = 0;
|
|
10068
10477
|
for (let e = 0; e < o2.length; e++) a2 += o2[e];
|
|
10069
|
-
let
|
|
10478
|
+
let c3 = a2 / o2.length, n3 = 0;
|
|
10070
10479
|
for (let e = 0; e < o2.length; e++) {
|
|
10071
|
-
let u = o2[e] -
|
|
10072
|
-
|
|
10480
|
+
let u = o2[e] - c3;
|
|
10481
|
+
n3 += u * u;
|
|
10073
10482
|
}
|
|
10074
|
-
let r =
|
|
10075
|
-
return 1 - (
|
|
10483
|
+
let r = n3 / o2.length, s = Math.sqrt(r);
|
|
10484
|
+
return 1 - (c3 > 0 ? s / c3 : 0);
|
|
10076
10485
|
}
|
|
10077
|
-
function on2(o2, a2,
|
|
10078
|
-
let t = r /
|
|
10079
|
-
for (let u = 0; u <
|
|
10080
|
-
let d2 = Math.min(Math.floor(
|
|
10486
|
+
function on2(o2, a2, c3, n3, r, s) {
|
|
10487
|
+
let t = r / c3, e = s / n3;
|
|
10488
|
+
for (let u = 0; u < s; u++) for (let i3 = 0; i3 < r; i3++) {
|
|
10489
|
+
let d2 = Math.min(Math.floor(i3 / t), c3 - 1), v = Math.min(Math.floor(u / e), n3 - 1), g2 = a2[v * c3 + d2], A = Math.floor(Math.max(0, Math.min(1, g2)) * 255), y = (u * r + i3) * 4;
|
|
10081
10490
|
o2[y] = A, o2[y + 1] = A, o2[y + 2] = A, o2[y + 3] = 255;
|
|
10082
10491
|
}
|
|
10083
10492
|
}
|
|
@@ -10085,7 +10494,7 @@ var en;
|
|
|
10085
10494
|
var init_hitchhikers_ssim = __esm({
|
|
10086
10495
|
"../ssim/dist/hitchhikers-ssim.mjs"() {
|
|
10087
10496
|
"use strict";
|
|
10088
|
-
en =
|
|
10497
|
+
en = h3;
|
|
10089
10498
|
}
|
|
10090
10499
|
});
|
|
10091
10500
|
|
|
@@ -10104,7 +10513,7 @@ Arguments:
|
|
|
10104
10513
|
|
|
10105
10514
|
Options:
|
|
10106
10515
|
-o, --output <path> Output path for SSIM map visualization
|
|
10107
|
-
--
|
|
10516
|
+
--codec <name> Specify codec to use (pngjs, sharp, jsquash-png)
|
|
10108
10517
|
--window-size <size> Window size (default: 11)
|
|
10109
10518
|
--window-stride <size> Window stride (default: windowSize for non-overlapping)
|
|
10110
10519
|
--no-cov-pooling Use mean pooling instead of CoV pooling
|
|
@@ -10143,21 +10552,21 @@ async function main6() {
|
|
|
10143
10552
|
const options = {
|
|
10144
10553
|
covPooling: true
|
|
10145
10554
|
};
|
|
10146
|
-
for (let
|
|
10147
|
-
const arg = args[
|
|
10148
|
-
const nextArg = args[
|
|
10555
|
+
for (let i3 = 2; i3 < args.length; i3++) {
|
|
10556
|
+
const arg = args[i3];
|
|
10557
|
+
const nextArg = args[i3 + 1];
|
|
10149
10558
|
switch (arg) {
|
|
10150
10559
|
case "-o":
|
|
10151
10560
|
case "--output":
|
|
10152
10561
|
if (nextArg) {
|
|
10153
10562
|
options.outputPath = nextArg;
|
|
10154
|
-
|
|
10563
|
+
i3++;
|
|
10155
10564
|
}
|
|
10156
10565
|
break;
|
|
10157
|
-
case "--
|
|
10566
|
+
case "--codec":
|
|
10158
10567
|
if (nextArg) {
|
|
10159
|
-
options.
|
|
10160
|
-
|
|
10568
|
+
options.codec = nextArg;
|
|
10569
|
+
i3++;
|
|
10161
10570
|
}
|
|
10162
10571
|
break;
|
|
10163
10572
|
case "--window-size":
|
|
@@ -10167,7 +10576,7 @@ async function main6() {
|
|
|
10167
10576
|
throw new Error(`Invalid window size: ${nextArg}`);
|
|
10168
10577
|
}
|
|
10169
10578
|
options.windowSize = size;
|
|
10170
|
-
|
|
10579
|
+
i3++;
|
|
10171
10580
|
}
|
|
10172
10581
|
break;
|
|
10173
10582
|
case "--window-stride":
|
|
@@ -10177,7 +10586,7 @@ async function main6() {
|
|
|
10177
10586
|
throw new Error(`Invalid window stride: ${nextArg}`);
|
|
10178
10587
|
}
|
|
10179
10588
|
options.windowStride = stride;
|
|
10180
|
-
|
|
10589
|
+
i3++;
|
|
10181
10590
|
}
|
|
10182
10591
|
break;
|
|
10183
10592
|
case "--no-cov-pooling":
|
|
@@ -10189,12 +10598,10 @@ async function main6() {
|
|
|
10189
10598
|
process.exit(1);
|
|
10190
10599
|
}
|
|
10191
10600
|
}
|
|
10192
|
-
const
|
|
10193
|
-
options.transformer
|
|
10194
|
-
);
|
|
10601
|
+
const codec = await getCodec5(options.codec);
|
|
10195
10602
|
const [img1, img2] = await Promise.all([
|
|
10196
|
-
|
|
10197
|
-
|
|
10603
|
+
codec.read(image1),
|
|
10604
|
+
codec.read(image2)
|
|
10198
10605
|
]);
|
|
10199
10606
|
if (img1.width !== img2.width || img1.height !== img2.height) {
|
|
10200
10607
|
throw new Error(
|
|
@@ -10226,7 +10633,7 @@ async function main6() {
|
|
|
10226
10633
|
);
|
|
10227
10634
|
const duration = performance.now() - startTime;
|
|
10228
10635
|
if (options.outputPath && outputData) {
|
|
10229
|
-
await
|
|
10636
|
+
await codec.write(
|
|
10230
10637
|
{
|
|
10231
10638
|
data: outputData,
|
|
10232
10639
|
width: img1.width,
|
|
@@ -10271,21 +10678,25 @@ async function main6() {
|
|
|
10271
10678
|
process.exit(1);
|
|
10272
10679
|
}
|
|
10273
10680
|
}
|
|
10274
|
-
var
|
|
10681
|
+
var getCodec5;
|
|
10275
10682
|
var init_hitchhikers_ssim2 = __esm({
|
|
10276
10683
|
"src/commands/hitchhikers-ssim.ts"() {
|
|
10277
10684
|
"use strict";
|
|
10278
10685
|
init_hitchhikers_ssim();
|
|
10279
|
-
|
|
10280
|
-
if (!
|
|
10281
|
-
const { default:
|
|
10282
|
-
return
|
|
10686
|
+
getCodec5 = async (codec) => {
|
|
10687
|
+
if (!codec || codec === "pngjs") {
|
|
10688
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
|
|
10689
|
+
return c3;
|
|
10690
|
+
}
|
|
10691
|
+
if (codec === "sharp") {
|
|
10692
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist3(), dist_exports2));
|
|
10693
|
+
return c3;
|
|
10283
10694
|
}
|
|
10284
|
-
if (
|
|
10285
|
-
const { default:
|
|
10286
|
-
return
|
|
10695
|
+
if (codec === "jsquash-png") {
|
|
10696
|
+
const { default: c3 } = await Promise.resolve().then(() => (init_dist4(), dist_exports3));
|
|
10697
|
+
return c3;
|
|
10287
10698
|
}
|
|
10288
|
-
throw new Error(`Unknown
|
|
10699
|
+
throw new Error(`Unknown codec: ${codec}`);
|
|
10289
10700
|
};
|
|
10290
10701
|
if (typeof require !== "undefined" && require.main === module) {
|
|
10291
10702
|
main6();
|
|
@@ -10315,6 +10726,7 @@ Examples:
|
|
|
10315
10726
|
blazediff-cli ssim image1.png image2.png -o ssim-map.png
|
|
10316
10727
|
blazediff-cli msssim image1.png image2.png
|
|
10317
10728
|
blazediff-cli hitchhikers-ssim image1.png image2.png
|
|
10729
|
+
blazediff-cli image1.png image2.png --interpret
|
|
10318
10730
|
|
|
10319
10731
|
# Default command (diff) if no command specified
|
|
10320
10732
|
blazediff-cli image1.png image2.png
|