@pixerate/editor 0.183.0 → 0.186.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-Y46OMERN.js → chunk-FW7N64XK.js} +298 -189
- package/dist/{chunk-UHMSMUHK.cjs → chunk-X2KQQZBT.cjs} +358 -249
- package/dist/image-editor/controller.d.cts +208 -8
- package/dist/image-editor/controller.d.ts +208 -8
- package/dist/image-editor/index.cjs +2610 -1025
- package/dist/image-editor/index.js +1672 -87
- package/dist/image-editor/layers/model.d.cts +5 -1
- package/dist/image-editor/layers/model.d.ts +5 -1
- package/dist/image-editor/layers/paint-ui.d.cts +2 -1
- package/dist/image-editor/layers/paint-ui.d.ts +2 -1
- package/dist/image-editor/layers/panel.d.cts +23 -1
- package/dist/image-editor/layers/panel.d.ts +23 -1
- package/dist/image-editor/layers/serialize.d.cts +3 -0
- package/dist/image-editor/layers/serialize.d.ts +3 -0
- package/dist/image-editor/psd/channels.d.cts +24 -0
- package/dist/image-editor/psd/channels.d.ts +24 -0
- package/dist/image-editor/psd/export.d.cts +3 -0
- package/dist/image-editor/psd/export.d.ts +3 -0
- package/dist/image-editor/psd/import.d.cts +10 -0
- package/dist/image-editor/psd/import.d.ts +10 -0
- package/dist/image-editor/renderer.d.cts +6 -0
- package/dist/image-editor/renderer.d.ts +6 -0
- package/dist/image-editor/selection/channels.d.cts +52 -0
- package/dist/image-editor/selection/channels.d.ts +52 -0
- package/dist/image-editor/selection/gesture.d.cts +47 -2
- package/dist/image-editor/selection/gesture.d.ts +47 -2
- package/dist/image-editor/selection/index.d.cts +2 -0
- package/dist/image-editor/selection/index.d.ts +2 -0
- package/dist/image-editor/selection/modify.d.cts +3 -2
- package/dist/image-editor/selection/modify.d.ts +3 -2
- package/dist/image-editor/selection/overlay.d.cts +2 -0
- package/dist/image-editor/selection/overlay.d.ts +2 -0
- package/dist/image-editor/selection/stroke.d.cts +8 -0
- package/dist/image-editor/selection/stroke.d.ts +8 -0
- package/dist/image-editor/selection/tool-options.d.cts +12 -2
- package/dist/image-editor/selection/tool-options.d.ts +12 -2
- package/dist/image-editor/selection/wand.d.cts +37 -0
- package/dist/image-editor/selection/wand.d.ts +37 -0
- package/dist/image-editor/selection-tools.d.cts +8 -3
- package/dist/image-editor/selection-tools.d.ts +8 -3
- package/dist/image-editor/tools.d.cts +10 -2
- package/dist/image-editor/tools.d.ts +10 -2
- package/dist/image-editor/types.d.cts +12 -0
- package/dist/image-editor/types.d.ts +12 -0
- package/dist/paint-editor/index.cjs +6 -6
- package/dist/paint-editor/index.js +1 -1
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +19 -21
- package/skills/pixerate-image-editor/references/free-transform.md +22 -0
- package/skills/pixerate-image-selection-masking/SKILL.md +36 -3
|
@@ -1192,7 +1192,7 @@ function shiftCoverage(src, w, h, amount) {
|
|
|
1192
1192
|
for (let i = 0; i < lo.length; i++) lo[i] += (hi[i] - lo[i]) * frac;
|
|
1193
1193
|
return lo;
|
|
1194
1194
|
}
|
|
1195
|
-
var SELECTION_MODIFY_OPS = ["
|
|
1195
|
+
var SELECTION_MODIFY_OPS = ["expand", "contract", "feather", "border", "smooth", "grow", "shrink"];
|
|
1196
1196
|
function wrap(mask, coverage) {
|
|
1197
1197
|
const out = new Uint8Array(coverage.length);
|
|
1198
1198
|
for (let i = 0; i < out.length; i++) out[i] = coverageToByte(coverage[i]);
|
|
@@ -1204,8 +1204,10 @@ function modifySelection(mask, op, radius) {
|
|
|
1204
1204
|
const m = selectionToCoverage(mask);
|
|
1205
1205
|
const { width: w, height: h } = mask;
|
|
1206
1206
|
switch (op) {
|
|
1207
|
+
case "expand":
|
|
1207
1208
|
case "grow":
|
|
1208
1209
|
return wrap(mask, expandCoverage(m, w, h, r));
|
|
1210
|
+
case "contract":
|
|
1209
1211
|
case "shrink":
|
|
1210
1212
|
return wrap(mask, contractCoverage(m, w, h, r));
|
|
1211
1213
|
case "feather":
|
|
@@ -6344,6 +6346,192 @@ function encodeLegacyName(s) {
|
|
|
6344
6346
|
return Uint8Array.from(out);
|
|
6345
6347
|
}
|
|
6346
6348
|
|
|
6349
|
+
// src/image-editor/psd/compression.ts
|
|
6350
|
+
var MAX_DECODED_BYTES = 2 ** 31;
|
|
6351
|
+
function rowBytes(width, depth) {
|
|
6352
|
+
return depth === 1 ? Math.ceil(width / 8) : width * Math.max(1, depth >> 3);
|
|
6353
|
+
}
|
|
6354
|
+
function decodedLength(l) {
|
|
6355
|
+
const total = l.planes * l.height * rowBytes(l.width, l.depth);
|
|
6356
|
+
if (total > MAX_DECODED_BYTES) throw new PsdError(`Decoded channel data of ${total} bytes is larger than the ${MAX_DECODED_BYTES}-byte limit.`);
|
|
6357
|
+
return total;
|
|
6358
|
+
}
|
|
6359
|
+
function packbitsBound(n) {
|
|
6360
|
+
return n + Math.ceil(n / 128);
|
|
6361
|
+
}
|
|
6362
|
+
function packbitsEncode(src, out, at) {
|
|
6363
|
+
const n = src.length;
|
|
6364
|
+
let i = 0;
|
|
6365
|
+
while (i < n) {
|
|
6366
|
+
let run = 1;
|
|
6367
|
+
while (i + run < n && run < 128 && src[i + run] === src[i]) run++;
|
|
6368
|
+
if (run >= 2) {
|
|
6369
|
+
out[at++] = 257 - run & 255;
|
|
6370
|
+
out[at++] = src[i];
|
|
6371
|
+
i += run;
|
|
6372
|
+
continue;
|
|
6373
|
+
}
|
|
6374
|
+
const start = i;
|
|
6375
|
+
let len = 0;
|
|
6376
|
+
while (i < n && len < 128) {
|
|
6377
|
+
if (i + 2 < n && src[i] === src[i + 1] && src[i] === src[i + 2]) break;
|
|
6378
|
+
i++;
|
|
6379
|
+
len++;
|
|
6380
|
+
}
|
|
6381
|
+
out[at++] = len - 1;
|
|
6382
|
+
out.set(src.subarray(start, start + len), at);
|
|
6383
|
+
at += len;
|
|
6384
|
+
}
|
|
6385
|
+
return at;
|
|
6386
|
+
}
|
|
6387
|
+
function packbitsDecodeInto(src, expected, out, at) {
|
|
6388
|
+
const target = at + expected;
|
|
6389
|
+
let i = 0;
|
|
6390
|
+
while (at < target) {
|
|
6391
|
+
if (i >= src.length) throw new PsdError("PackBits row ended early.");
|
|
6392
|
+
const h = src[i++];
|
|
6393
|
+
if (h < 128) {
|
|
6394
|
+
const len = h + 1;
|
|
6395
|
+
if (i + len > src.length) throw new PsdError("PackBits literal is truncated.");
|
|
6396
|
+
if (at + len > target) throw new PsdError("PackBits literal overflows its row.");
|
|
6397
|
+
out.set(src.subarray(i, i + len), at);
|
|
6398
|
+
at += len;
|
|
6399
|
+
i += len;
|
|
6400
|
+
} else if (h !== 128) {
|
|
6401
|
+
const len = 257 - h;
|
|
6402
|
+
if (i >= src.length) throw new PsdError("PackBits run is truncated.");
|
|
6403
|
+
const b = src[i++];
|
|
6404
|
+
if (at + len > target) throw new PsdError("PackBits run overflows its row.");
|
|
6405
|
+
out.fill(b, at, at + len);
|
|
6406
|
+
at += len;
|
|
6407
|
+
}
|
|
6408
|
+
}
|
|
6409
|
+
return at;
|
|
6410
|
+
}
|
|
6411
|
+
function inflateChecked(data, expected) {
|
|
6412
|
+
let out;
|
|
6413
|
+
try {
|
|
6414
|
+
out = _chunkXFM3OCHUcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
6415
|
+
} catch (e) {
|
|
6416
|
+
throw new PsdError(`ZIP channel data: ${e instanceof _chunkXFM3OCHUcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
6417
|
+
}
|
|
6418
|
+
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
6419
|
+
return out.length === expected ? out : out.subarray(0, expected);
|
|
6420
|
+
}
|
|
6421
|
+
function unpredict(buf, l) {
|
|
6422
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6423
|
+
if (rb === 0) return;
|
|
6424
|
+
const w = l.width;
|
|
6425
|
+
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
6426
|
+
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
6427
|
+
if (l.depth === 1 || l.depth === 8) {
|
|
6428
|
+
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
6429
|
+
} else if (l.depth === 16) {
|
|
6430
|
+
for (let i = 1; i < w; i++) {
|
|
6431
|
+
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
6432
|
+
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
6433
|
+
const v = a + b & 65535;
|
|
6434
|
+
buf[o + 2 * i] = v >> 8;
|
|
6435
|
+
buf[o + 2 * i + 1] = v & 255;
|
|
6436
|
+
}
|
|
6437
|
+
} else if (l.depth === 32) {
|
|
6438
|
+
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
6439
|
+
scratch.set(buf.subarray(o, o + rb));
|
|
6440
|
+
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + 4 * i + k] = scratch[k * w + i];
|
|
6441
|
+
} else {
|
|
6442
|
+
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
}
|
|
6446
|
+
function decodeRle(r, l, total) {
|
|
6447
|
+
const rows = l.planes * l.height;
|
|
6448
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6449
|
+
r.checkCount(rows, l.psb ? 4 : 2, "RLE row counts");
|
|
6450
|
+
const counts = new Array(rows);
|
|
6451
|
+
for (let i = 0; i < rows; i++) counts[i] = l.psb ? r.u32() : r.u16();
|
|
6452
|
+
if (total > r.remaining * 130) throw new PsdError("RLE data is too short for its declared size.");
|
|
6453
|
+
const out = new Uint8Array(total);
|
|
6454
|
+
let at = 0;
|
|
6455
|
+
for (const c of counts) at = packbitsDecodeInto(r.bytes(c), rb, out, at);
|
|
6456
|
+
return out;
|
|
6457
|
+
}
|
|
6458
|
+
function decodePlanes(compression, data, l) {
|
|
6459
|
+
const total = decodedLength(l);
|
|
6460
|
+
switch (compression) {
|
|
6461
|
+
case 0:
|
|
6462
|
+
if (data.length < total) throw new PsdError(`Raw channel data has ${data.length} of ${total} bytes.`);
|
|
6463
|
+
return data.slice(0, total);
|
|
6464
|
+
case 1:
|
|
6465
|
+
return decodeRle(new PsdReader(data), l, total);
|
|
6466
|
+
case 2:
|
|
6467
|
+
return inflateChecked(data, total).slice();
|
|
6468
|
+
case 3: {
|
|
6469
|
+
const v = inflateChecked(data, total).slice();
|
|
6470
|
+
unpredict(v, l);
|
|
6471
|
+
return v;
|
|
6472
|
+
}
|
|
6473
|
+
default:
|
|
6474
|
+
throw new PsdError(`Unsupported compression method ${compression}.`);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
function encodeRle(decoded2, l) {
|
|
6478
|
+
const rows = l.planes * l.height;
|
|
6479
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6480
|
+
const cs = l.psb ? 4 : 2;
|
|
6481
|
+
const packed = new Uint8Array(rows * packbitsBound(rb));
|
|
6482
|
+
let at = 0;
|
|
6483
|
+
const counts = new Uint8Array(rows * cs);
|
|
6484
|
+
for (let row = 0; row < rows; row++) {
|
|
6485
|
+
const start = at;
|
|
6486
|
+
at = packbitsEncode(decoded2.subarray(row * rb, (row + 1) * rb), packed, at);
|
|
6487
|
+
const n = at - start;
|
|
6488
|
+
if (cs === 2) {
|
|
6489
|
+
if (n > 65535) throw new PsdError("An RLE row is longer than 65535 bytes; write a PSB instead.");
|
|
6490
|
+
counts[row * 2] = n >> 8;
|
|
6491
|
+
counts[row * 2 + 1] = n & 255;
|
|
6492
|
+
} else {
|
|
6493
|
+
counts[row * 4] = n >>> 24;
|
|
6494
|
+
counts[row * 4 + 1] = n >>> 16 & 255;
|
|
6495
|
+
counts[row * 4 + 2] = n >>> 8 & 255;
|
|
6496
|
+
counts[row * 4 + 3] = n & 255;
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
const out = new Uint8Array(counts.length + at);
|
|
6500
|
+
out.set(counts);
|
|
6501
|
+
out.set(packed.subarray(0, at), counts.length);
|
|
6502
|
+
return out;
|
|
6503
|
+
}
|
|
6504
|
+
function predict(buf, l) {
|
|
6505
|
+
const rb = rowBytes(l.width, l.depth);
|
|
6506
|
+
if (rb === 0) return;
|
|
6507
|
+
const w = l.width;
|
|
6508
|
+
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
6509
|
+
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
6510
|
+
if (l.depth === 1 || l.depth === 8) {
|
|
6511
|
+
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
6512
|
+
} else if (l.depth === 16) {
|
|
6513
|
+
for (let i = w - 1; i > 0; i--) {
|
|
6514
|
+
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
6515
|
+
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
6516
|
+
const v = a - b & 65535;
|
|
6517
|
+
buf[o + 2 * i] = v >> 8;
|
|
6518
|
+
buf[o + 2 * i + 1] = v & 255;
|
|
6519
|
+
}
|
|
6520
|
+
} else if (l.depth === 32) {
|
|
6521
|
+
scratch.set(buf.subarray(o, o + rb));
|
|
6522
|
+
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + k * w + i] = scratch[4 * i + k];
|
|
6523
|
+
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
6524
|
+
} else {
|
|
6525
|
+
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
6526
|
+
}
|
|
6527
|
+
}
|
|
6528
|
+
}
|
|
6529
|
+
function encodeZipPredicted(decoded2, l) {
|
|
6530
|
+
const buf = decoded2.slice();
|
|
6531
|
+
predict(buf, l);
|
|
6532
|
+
return _chunkXFM3OCHUcjs.deflate.call(void 0, buf);
|
|
6533
|
+
}
|
|
6534
|
+
|
|
6347
6535
|
// src/image-editor/psd/descriptor.ts
|
|
6348
6536
|
var MAX_DEPTH = 64;
|
|
6349
6537
|
var STRING_IDS = /* @__PURE__ */ new Set(["warp", "list", "time"]);
|
|
@@ -6943,6 +7131,97 @@ function writeAdjustmentBlock(kind, params) {
|
|
|
6943
7131
|
throw new Error(`Unknown adjustment kind "${kind}".`);
|
|
6944
7132
|
}
|
|
6945
7133
|
|
|
7134
|
+
// src/image-editor/psd/channels.ts
|
|
7135
|
+
var hexToRgb2 = (hex) => {
|
|
7136
|
+
const v = parseInt(_nullishCoalesce(_optionalChain([/^#?([0-9a-f]{6})$/i, 'access', _181 => _181.exec, 'call', _182 => _182(hex), 'optionalAccess', _183 => _183[1]]), () => ( "ff0000")), 16);
|
|
7137
|
+
return [v >> 16 & 255, v >> 8 & 255, v & 255];
|
|
7138
|
+
};
|
|
7139
|
+
var rgbToHex = (r, g, b) => `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
|
|
7140
|
+
function alphaChannelResources(channels) {
|
|
7141
|
+
if (!channels.length) return [];
|
|
7142
|
+
const names = new PsdWriter();
|
|
7143
|
+
for (const c of channels) names.pascal(encodeLegacyName(c.name), 1);
|
|
7144
|
+
const unicode = new PsdWriter();
|
|
7145
|
+
for (const c of channels) unicode.unicode(c.name);
|
|
7146
|
+
const display = new PsdWriter();
|
|
7147
|
+
display.u32(1);
|
|
7148
|
+
for (const c of channels) {
|
|
7149
|
+
const [r, g, b] = hexToRgb2(c.color);
|
|
7150
|
+
display.u16(0);
|
|
7151
|
+
for (const v of [r, g, b, 0]) display.u16(v * 257);
|
|
7152
|
+
display.u16(Math.round(Math.min(1, Math.max(0, c.opacity)) * 100));
|
|
7153
|
+
display.u8(c.indicates === "selected" ? 0 : 1);
|
|
7154
|
+
display.u8(0);
|
|
7155
|
+
}
|
|
7156
|
+
return [
|
|
7157
|
+
{ id: 1006, name: "", data: names.result() },
|
|
7158
|
+
{ id: 1045, name: "", data: unicode.result() },
|
|
7159
|
+
{ id: 1077, name: "", data: display.result() }
|
|
7160
|
+
];
|
|
7161
|
+
}
|
|
7162
|
+
function planeTo8(plane, n, depth) {
|
|
7163
|
+
if (depth === 8) return plane.slice(0, n);
|
|
7164
|
+
const out = new Uint8Array(n);
|
|
7165
|
+
const view = new DataView(plane.buffer, plane.byteOffset, plane.byteLength);
|
|
7166
|
+
for (let i = 0; i < n; i++) {
|
|
7167
|
+
if (depth === 16) out[i] = plane[2 * i];
|
|
7168
|
+
else out[i] = Math.round(Math.min(1, Math.max(0, view.getFloat32(4 * i, false))) * 255);
|
|
7169
|
+
}
|
|
7170
|
+
return out;
|
|
7171
|
+
}
|
|
7172
|
+
function readAlphaChannels(planes, header, first, resource2, warn) {
|
|
7173
|
+
const count = header.channels - first;
|
|
7174
|
+
if (count <= 0 || header.depth === 1) return [];
|
|
7175
|
+
const size = rowBytes(header.width, header.depth) * header.height;
|
|
7176
|
+
const n = header.width * header.height;
|
|
7177
|
+
const names = [];
|
|
7178
|
+
const unicode = resource2(1045);
|
|
7179
|
+
if (unicode) {
|
|
7180
|
+
const r = new PsdReader(unicode);
|
|
7181
|
+
while (r.remaining >= 4 && names.length < count) names.push(r.unicode().replace(/\0+$/, ""));
|
|
7182
|
+
} else {
|
|
7183
|
+
const legacy = resource2(1006);
|
|
7184
|
+
if (legacy) {
|
|
7185
|
+
const r = new PsdReader(legacy);
|
|
7186
|
+
while (r.remaining >= 1 && names.length < count) names.push(new TextDecoder("latin1").decode(r.pascal(1)));
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
const display = [];
|
|
7190
|
+
const info = resource2(1077);
|
|
7191
|
+
if (info && info.length >= 4) {
|
|
7192
|
+
const r = new PsdReader(info);
|
|
7193
|
+
r.u32();
|
|
7194
|
+
while (r.remaining >= 14 && display.length < count) {
|
|
7195
|
+
r.u16();
|
|
7196
|
+
const [cr, cg, cb] = [r.u16(), r.u16(), r.u16()];
|
|
7197
|
+
r.u16();
|
|
7198
|
+
const opacity = r.u16();
|
|
7199
|
+
const kind = r.u8();
|
|
7200
|
+
r.u8();
|
|
7201
|
+
display.push({ color: rgbToHex(cr >> 8, cg >> 8, cb >> 8), opacity: Math.min(100, opacity) / 100, kind });
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
const out = [];
|
|
7205
|
+
for (let i = 0; i < count; i++) {
|
|
7206
|
+
const start = (first + i) * size;
|
|
7207
|
+
if (start + size > planes.length) break;
|
|
7208
|
+
const d = display[i];
|
|
7209
|
+
const name = names[i] || `Alpha ${i + 1}`;
|
|
7210
|
+
if (_optionalChain([d, 'optionalAccess', _184 => _184.kind]) === 2) {
|
|
7211
|
+
warn(`Spot colour channel "${name}" is not supported and was left out.`);
|
|
7212
|
+
continue;
|
|
7213
|
+
}
|
|
7214
|
+
out.push({
|
|
7215
|
+
name,
|
|
7216
|
+
data: planeTo8(planes.subarray(start, start + size), n, header.depth),
|
|
7217
|
+
color: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _185 => _185.color]), () => ( "#ff0000")),
|
|
7218
|
+
opacity: _nullishCoalesce(_optionalChain([d, 'optionalAccess', _186 => _186.opacity]), () => ( 0.5)),
|
|
7219
|
+
indicates: _optionalChain([d, 'optionalAccess', _187 => _187.kind]) === 0 ? "selected" : "masked"
|
|
7220
|
+
});
|
|
7221
|
+
}
|
|
7222
|
+
return out;
|
|
7223
|
+
}
|
|
7224
|
+
|
|
6946
7225
|
// src/image-editor/psd/paths.ts
|
|
6947
7226
|
var RECORD = 26;
|
|
6948
7227
|
var fixed = (v) => v / 16777216;
|
|
@@ -7082,7 +7361,7 @@ var enumV = (typeId, value) => ({ type: "enum", typeId, value });
|
|
|
7082
7361
|
var obj = (d) => ({ type: "Objc", value: d });
|
|
7083
7362
|
var enumOf = (d, key) => {
|
|
7084
7363
|
const v = descGet(d, key);
|
|
7085
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7364
|
+
return _optionalChain([v, 'optionalAccess', _188 => _188.type]) === "enum" ? v.value : void 0;
|
|
7086
7365
|
};
|
|
7087
7366
|
function read(data) {
|
|
7088
7367
|
try {
|
|
@@ -7164,7 +7443,7 @@ function strokeFromVstk(data, dpi, notes) {
|
|
|
7164
7443
|
const miter = descNumber(d, "strokeStyleMiterLimit");
|
|
7165
7444
|
if (miter !== void 0 && miter !== 100) stroke.miterLimit = Math.max(1, Math.min(500, miter));
|
|
7166
7445
|
const dashes = descGet(d, "strokeStyleLineDashSet");
|
|
7167
|
-
if (_optionalChain([dashes, 'optionalAccess',
|
|
7446
|
+
if (_optionalChain([dashes, 'optionalAccess', _189 => _189.type]) === "VlLs") {
|
|
7168
7447
|
const list2 = dashes.items.map((v) => v.type === "UntF" || v.type === "doub" || v.type === "long" ? v.value : NaN).filter((v) => Number.isFinite(v) && v >= 0);
|
|
7169
7448
|
if (list2.length && list2.some((v) => v > 0)) stroke.dashes = list2;
|
|
7170
7449
|
}
|
|
@@ -7316,7 +7595,7 @@ function vogkBytes(components, dpi) {
|
|
|
7316
7595
|
["keyOriginLineArrowEnd", boolV(Boolean(live.endArrow))],
|
|
7317
7596
|
["keyOriginLineArrWdth", dbl(head ? head.width / w * 100 : 0)],
|
|
7318
7597
|
["keyOriginLineArrLngth", dbl(head ? head.length / w * 100 : 0)],
|
|
7319
|
-
["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess',
|
|
7598
|
+
["keyOriginLineArrConc", long2(_optionalChain([head, 'optionalAccess', _190 => _190.concavity]) ? head.concavity * 100 : 0)]
|
|
7320
7599
|
];
|
|
7321
7600
|
}
|
|
7322
7601
|
const m = live.transform;
|
|
@@ -7349,7 +7628,7 @@ function shapeSignature(layer) {
|
|
|
7349
7628
|
return JSON.stringify([layer.components, layer.fill, layer.stroke, _nullishCoalesce(layer.fillRule, () => ( "nonzero")), Boolean(layer.inverted)]);
|
|
7350
7629
|
}
|
|
7351
7630
|
function shapeFromBlocks(blocks, width, height, dpi, notes) {
|
|
7352
|
-
const block = (k) => _optionalChain([blocks, 'access',
|
|
7631
|
+
const block = (k) => _optionalChain([blocks, 'access', _191 => _191.find, 'call', _192 => _192((b) => b.key === k), 'optionalAccess', _193 => _193.data]);
|
|
7353
7632
|
const vector = _nullishCoalesce(block("vsms"), () => ( block("vmsk")));
|
|
7354
7633
|
const path = vector ? componentsFromVectorBlock(vector, width, height) : null;
|
|
7355
7634
|
if (!path) return null;
|
|
@@ -7404,18 +7683,18 @@ function sameExtent(sub, c) {
|
|
|
7404
7683
|
return a.every((v, i) => Math.abs(v - b[i]) < 1);
|
|
7405
7684
|
}
|
|
7406
7685
|
function shapeBlocks(layer, width, height, dpi, notes) {
|
|
7407
|
-
const kept = _optionalChain([layer, 'access',
|
|
7408
|
-
if (_optionalChain([kept, 'optionalAccess',
|
|
7686
|
+
const kept = _optionalChain([layer, 'access', _194 => _194.psd, 'optionalAccess', _195 => _195.blocks]);
|
|
7687
|
+
if (_optionalChain([kept, 'optionalAccess', _196 => _196.length]) && _optionalChain([layer, 'access', _197 => _197.psd, 'optionalAccess', _198 => _198.signature]) === shapeSignature(layer)) return kept.map((b) => ({ key: b.key, data: b.data }));
|
|
7409
7688
|
const out = [];
|
|
7410
7689
|
out.push({ key: "vsms", data: vectorBlockForComponents(layer.components, Boolean(layer.inverted), width, height) });
|
|
7411
7690
|
if (layer.fillRule === "evenodd" && layer.components.some((c) => c.subpaths.length > 1)) notes.add("Even-odd fill rules were written as nonzero (Photoshop fills shapes nonzero)");
|
|
7412
7691
|
const fill = _nullishCoalesce(layer.fill, () => ( { type: "color", color: "#000000" }));
|
|
7413
|
-
if (_optionalChain([layer, 'access',
|
|
7692
|
+
if (_optionalChain([layer, 'access', _199 => _199.fill, 'optionalAccess', _200 => _200.opacity]) !== void 0 && layer.fill.opacity < 1) notes.add("Shape fill opacity has no PSD equivalent and was written as 100 % (use the layer fill opacity)");
|
|
7414
7693
|
out.push({ key: "vscg", data: vscgBytes(fill) });
|
|
7415
7694
|
if (layer.stroke || !layer.fill) out.push({ key: "vstk", data: vstkBytes(layer.stroke, Boolean(layer.fill), dpi) });
|
|
7416
7695
|
const vogk = vogkBytes(layer.components, dpi);
|
|
7417
7696
|
if (vogk) out.push({ key: "vogk", data: vogk });
|
|
7418
|
-
if (layer.components.some((c) => _optionalChain([c, 'access',
|
|
7697
|
+
if (layer.components.some((c) => _optionalChain([c, 'access', _201 => _201.live, 'optionalAccess', _202 => _202.kind]) === "line" && (c.live.startArrow && c.live.endArrow && JSON.stringify(c.live.startArrow) !== JSON.stringify(c.live.endArrow) || false))) {
|
|
7419
7698
|
notes.add("Lines with different start and end arrowheads were written with one arrowhead size (Photoshop has one)");
|
|
7420
7699
|
}
|
|
7421
7700
|
return out;
|
|
@@ -7624,7 +7903,7 @@ var E = {
|
|
|
7624
7903
|
bool: (value) => ({ t: "bool", value })
|
|
7625
7904
|
};
|
|
7626
7905
|
function eGet(v, key) {
|
|
7627
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7906
|
+
return _optionalChain([v, 'optionalAccess', _203 => _203.t]) === "dict" ? _optionalChain([v, 'access', _204 => _204.items, 'access', _205 => _205.find, 'call', _206 => _206(([k]) => k === key), 'optionalAccess', _207 => _207[1]]) : void 0;
|
|
7628
7907
|
}
|
|
7629
7908
|
function ePath(v, keys) {
|
|
7630
7909
|
return keys.reduce((at, k) => eGet(at, k), v);
|
|
@@ -7642,7 +7921,7 @@ function eStr(v) {
|
|
|
7642
7921
|
return v && (v.t === "string" || v.t === "name") ? v.value : void 0;
|
|
7643
7922
|
}
|
|
7644
7923
|
function eArray(v) {
|
|
7645
|
-
return _optionalChain([v, 'optionalAccess',
|
|
7924
|
+
return _optionalChain([v, 'optionalAccess', _208 => _208.t]) === "array" ? v.items : [];
|
|
7646
7925
|
}
|
|
7647
7926
|
function eSet(d, key, value) {
|
|
7648
7927
|
if (d.t !== "dict") return;
|
|
@@ -7744,7 +8023,7 @@ function fontFromPostScript(ps) {
|
|
|
7744
8023
|
}
|
|
7745
8024
|
family += suffix;
|
|
7746
8025
|
const s = style.toLowerCase();
|
|
7747
|
-
const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access',
|
|
8026
|
+
const weight = _nullishCoalesce(_optionalChain([WEIGHTS, 'access', _209 => _209.find, 'call', _210 => _210(([re]) => re.test(s)), 'optionalAccess', _211 => _211[1]]), () => ( 400));
|
|
7748
8027
|
return { family: family || ps, weight, italic: /italic|oblique|it$/.test(s) };
|
|
7749
8028
|
}
|
|
7750
8029
|
var STYLE_NAMES = [
|
|
@@ -7769,7 +8048,7 @@ var hex2 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).pad
|
|
|
7769
8048
|
function merged(levels) {
|
|
7770
8049
|
const items = [];
|
|
7771
8050
|
for (const l of levels) {
|
|
7772
|
-
if (_optionalChain([l, 'optionalAccess',
|
|
8051
|
+
if (_optionalChain([l, 'optionalAccess', _212 => _212.t]) !== "dict") continue;
|
|
7773
8052
|
for (const [k, v] of l.items) if (!items.some(([o]) => o === k)) items.push([k, v]);
|
|
7774
8053
|
}
|
|
7775
8054
|
return E.dict(items);
|
|
@@ -7840,10 +8119,10 @@ function typeFromTySh(data, notes) {
|
|
|
7840
8119
|
const t = parseTySh(data);
|
|
7841
8120
|
if (!t) return null;
|
|
7842
8121
|
const txtV = descGet(t.text, "Txt ");
|
|
7843
|
-
const txt = _optionalChain([txtV, 'optionalAccess',
|
|
8122
|
+
const txt = _optionalChain([txtV, 'optionalAccess', _213 => _213.type]) === "TEXT" ? txtV.value.replace(/\0+$/, "") : void 0;
|
|
7844
8123
|
const ed = descGet(t.text, "EngineData");
|
|
7845
8124
|
let engine = null;
|
|
7846
|
-
if (_optionalChain([ed, 'optionalAccess',
|
|
8125
|
+
if (_optionalChain([ed, 'optionalAccess', _214 => _214.type]) === "tdta") {
|
|
7847
8126
|
try {
|
|
7848
8127
|
engine = parseEngineData(ed.data);
|
|
7849
8128
|
} catch (e18) {
|
|
@@ -7851,12 +8130,12 @@ function typeFromTySh(data, notes) {
|
|
|
7851
8130
|
}
|
|
7852
8131
|
}
|
|
7853
8132
|
const anti = descGet(t.text, "AntA");
|
|
7854
|
-
const antiAlias = !(_optionalChain([anti, 'optionalAccess',
|
|
8133
|
+
const antiAlias = !(_optionalChain([anti, 'optionalAccess', _215 => _215.type]) === "enum" && (anti.value === "Anno" || anti.value === "antiAliasNone"));
|
|
7855
8134
|
const ornt = descGet(t.text, "Ornt");
|
|
7856
|
-
if (_optionalChain([ornt, 'optionalAccess',
|
|
8135
|
+
if (_optionalChain([ornt, 'optionalAccess', _216 => _216.type]) === "enum" && ornt.value === "Vrtc") notes.add("vertical type is laid out horizontally");
|
|
7857
8136
|
if (t.warp) {
|
|
7858
8137
|
const style = descGet(t.warp, "warpStyle");
|
|
7859
|
-
if (_optionalChain([style, 'optionalAccess',
|
|
8138
|
+
if (_optionalChain([style, 'optionalAccess', _217 => _217.type]) === "enum" && style.value !== "warpNone") notes.add("warped text is drawn without its warp when edited");
|
|
7860
8139
|
}
|
|
7861
8140
|
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
7862
8141
|
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
@@ -7905,7 +8184,7 @@ function typeFromTySh(data, notes) {
|
|
|
7905
8184
|
let at = 0;
|
|
7906
8185
|
runs = ssheets.map((sheet, i) => {
|
|
7907
8186
|
const own = named(styleSet, sheet);
|
|
7908
|
-
const paraDefault = _optionalChain([paraBases, 'access',
|
|
8187
|
+
const paraDefault = _optionalChain([paraBases, 'access', _218 => _218[paraAt(at)], 'optionalAccess', _219 => _219.charDefault]);
|
|
7909
8188
|
at += _nullishCoalesce(slens[i], () => ( 0));
|
|
7910
8189
|
const d = merged([eGet(sheet, "StyleSheetData"), eGet(own, "StyleSheetData"), eGet(paraDefault, "StyleSheetData"), eGet(normalStyle, "StyleSheetData")]);
|
|
7911
8190
|
return { length: _nullishCoalesce(slens[i], () => ( 0)), style: charStyle(d, fonts, notes) };
|
|
@@ -7984,8 +8263,8 @@ var fontEntry = (name) => E.dict([
|
|
|
7984
8263
|
["Synthetic", E.int(0)]
|
|
7985
8264
|
]);
|
|
7986
8265
|
function buildEngineData(layer, template) {
|
|
7987
|
-
const e = _optionalChain([template, 'optionalAccess',
|
|
7988
|
-
if (_optionalChain([eGet, 'call',
|
|
8266
|
+
const e = _optionalChain([template, 'optionalAccess', _220 => _220.t]) === "dict" ? eClone(template) : E.dict([["EngineDict", E.dict()], ["ResourceDict", E.dict()]]);
|
|
8267
|
+
if (_optionalChain([eGet, 'call', _221 => _221(e, "EngineDict"), 'optionalAccess', _222 => _222.t]) !== "dict") eSet(e, "EngineDict", E.dict());
|
|
7989
8268
|
const dict = eGet(e, "EngineDict");
|
|
7990
8269
|
const text3 = layer.text.replace(/\n/g, "\r");
|
|
7991
8270
|
const edText = `${text3}\r`;
|
|
@@ -8064,7 +8343,7 @@ function buildEngineData(layer, template) {
|
|
|
8064
8343
|
eSet(e, key, rd);
|
|
8065
8344
|
}
|
|
8066
8345
|
eSet(rd, "FontSet", fontSet);
|
|
8067
|
-
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access',
|
|
8346
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _223 => _223[0], 'optionalAccess', _224 => _224.style]), () => ( _chunkEGZM52EOcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8068
8347
|
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8069
8348
|
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8070
8349
|
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
@@ -8085,12 +8364,12 @@ function inkBounds2(layer) {
|
|
|
8085
8364
|
return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
|
|
8086
8365
|
}
|
|
8087
8366
|
function tyShForLayer(layer) {
|
|
8088
|
-
const raw = _optionalChain([layer, 'access',
|
|
8089
|
-
if (raw && _optionalChain([layer, 'access',
|
|
8367
|
+
const raw = _optionalChain([layer, 'access', _225 => _225.psd, 'optionalAccess', _226 => _226.tySh]);
|
|
8368
|
+
if (raw && _optionalChain([layer, 'access', _227 => _227.psd, 'optionalAccess', _228 => _228.signature]) === typeSignature(layer)) return raw;
|
|
8090
8369
|
const old = raw ? parseTySh(raw) : null;
|
|
8091
8370
|
const oldEd = old ? descGet(old.text, "EngineData") : void 0;
|
|
8092
8371
|
let template = null;
|
|
8093
|
-
if (_optionalChain([oldEd, 'optionalAccess',
|
|
8372
|
+
if (_optionalChain([oldEd, 'optionalAccess', _229 => _229.type]) === "tdta") {
|
|
8094
8373
|
try {
|
|
8095
8374
|
template = parseEngineData(oldEd.data);
|
|
8096
8375
|
} catch (e19) {
|
|
@@ -8122,197 +8401,11 @@ function tyShForLayer(layer) {
|
|
|
8122
8401
|
set("boundingBox", rect("boundingBox"));
|
|
8123
8402
|
if (!descGet(text3, "TextIndex")) set("TextIndex", { type: "long", value: 0 });
|
|
8124
8403
|
set("EngineData", { type: "tdta", data: writeEngineData(engine) });
|
|
8125
|
-
const warpStyle = _optionalChain([old, 'optionalAccess',
|
|
8126
|
-
const warp = _optionalChain([old, 'optionalAccess',
|
|
8404
|
+
const warpStyle = _optionalChain([old, 'optionalAccess', _230 => _230.warp]) ? descGet(old.warp, "warpStyle") : void 0;
|
|
8405
|
+
const warp = _optionalChain([old, 'optionalAccess', _231 => _231.warp]) && _optionalChain([warpStyle, 'optionalAccess', _232 => _232.type]) === "enum" && warpStyle.value === "warpNone" ? old.warp : null;
|
|
8127
8406
|
return writeTySh({ transform: textMatrix(layer), text: text3, warp, tail: new Uint8Array(16) });
|
|
8128
8407
|
}
|
|
8129
8408
|
|
|
8130
|
-
// src/image-editor/psd/compression.ts
|
|
8131
|
-
var MAX_DECODED_BYTES = 2 ** 31;
|
|
8132
|
-
function rowBytes(width, depth) {
|
|
8133
|
-
return depth === 1 ? Math.ceil(width / 8) : width * Math.max(1, depth >> 3);
|
|
8134
|
-
}
|
|
8135
|
-
function decodedLength(l) {
|
|
8136
|
-
const total = l.planes * l.height * rowBytes(l.width, l.depth);
|
|
8137
|
-
if (total > MAX_DECODED_BYTES) throw new PsdError(`Decoded channel data of ${total} bytes is larger than the ${MAX_DECODED_BYTES}-byte limit.`);
|
|
8138
|
-
return total;
|
|
8139
|
-
}
|
|
8140
|
-
function packbitsBound(n) {
|
|
8141
|
-
return n + Math.ceil(n / 128);
|
|
8142
|
-
}
|
|
8143
|
-
function packbitsEncode(src, out, at) {
|
|
8144
|
-
const n = src.length;
|
|
8145
|
-
let i = 0;
|
|
8146
|
-
while (i < n) {
|
|
8147
|
-
let run = 1;
|
|
8148
|
-
while (i + run < n && run < 128 && src[i + run] === src[i]) run++;
|
|
8149
|
-
if (run >= 2) {
|
|
8150
|
-
out[at++] = 257 - run & 255;
|
|
8151
|
-
out[at++] = src[i];
|
|
8152
|
-
i += run;
|
|
8153
|
-
continue;
|
|
8154
|
-
}
|
|
8155
|
-
const start = i;
|
|
8156
|
-
let len = 0;
|
|
8157
|
-
while (i < n && len < 128) {
|
|
8158
|
-
if (i + 2 < n && src[i] === src[i + 1] && src[i] === src[i + 2]) break;
|
|
8159
|
-
i++;
|
|
8160
|
-
len++;
|
|
8161
|
-
}
|
|
8162
|
-
out[at++] = len - 1;
|
|
8163
|
-
out.set(src.subarray(start, start + len), at);
|
|
8164
|
-
at += len;
|
|
8165
|
-
}
|
|
8166
|
-
return at;
|
|
8167
|
-
}
|
|
8168
|
-
function packbitsDecodeInto(src, expected, out, at) {
|
|
8169
|
-
const target = at + expected;
|
|
8170
|
-
let i = 0;
|
|
8171
|
-
while (at < target) {
|
|
8172
|
-
if (i >= src.length) throw new PsdError("PackBits row ended early.");
|
|
8173
|
-
const h = src[i++];
|
|
8174
|
-
if (h < 128) {
|
|
8175
|
-
const len = h + 1;
|
|
8176
|
-
if (i + len > src.length) throw new PsdError("PackBits literal is truncated.");
|
|
8177
|
-
if (at + len > target) throw new PsdError("PackBits literal overflows its row.");
|
|
8178
|
-
out.set(src.subarray(i, i + len), at);
|
|
8179
|
-
at += len;
|
|
8180
|
-
i += len;
|
|
8181
|
-
} else if (h !== 128) {
|
|
8182
|
-
const len = 257 - h;
|
|
8183
|
-
if (i >= src.length) throw new PsdError("PackBits run is truncated.");
|
|
8184
|
-
const b = src[i++];
|
|
8185
|
-
if (at + len > target) throw new PsdError("PackBits run overflows its row.");
|
|
8186
|
-
out.fill(b, at, at + len);
|
|
8187
|
-
at += len;
|
|
8188
|
-
}
|
|
8189
|
-
}
|
|
8190
|
-
return at;
|
|
8191
|
-
}
|
|
8192
|
-
function inflateChecked(data, expected) {
|
|
8193
|
-
let out;
|
|
8194
|
-
try {
|
|
8195
|
-
out = _chunkXFM3OCHUcjs.inflate.call(void 0, data, { maxOutput: expected + (1 << 20), sizeHint: expected, verify: false });
|
|
8196
|
-
} catch (e) {
|
|
8197
|
-
throw new PsdError(`ZIP channel data: ${e instanceof _chunkXFM3OCHUcjs.ZlibError || e instanceof Error ? e.message : String(e)}`);
|
|
8198
|
-
}
|
|
8199
|
-
if (out.length < expected) throw new PsdError(`ZIP stream produced ${out.length} of ${expected} bytes.`);
|
|
8200
|
-
return out.length === expected ? out : out.subarray(0, expected);
|
|
8201
|
-
}
|
|
8202
|
-
function unpredict(buf, l) {
|
|
8203
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8204
|
-
if (rb === 0) return;
|
|
8205
|
-
const w = l.width;
|
|
8206
|
-
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
8207
|
-
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
8208
|
-
if (l.depth === 1 || l.depth === 8) {
|
|
8209
|
-
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
8210
|
-
} else if (l.depth === 16) {
|
|
8211
|
-
for (let i = 1; i < w; i++) {
|
|
8212
|
-
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
8213
|
-
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
8214
|
-
const v = a + b & 65535;
|
|
8215
|
-
buf[o + 2 * i] = v >> 8;
|
|
8216
|
-
buf[o + 2 * i + 1] = v & 255;
|
|
8217
|
-
}
|
|
8218
|
-
} else if (l.depth === 32) {
|
|
8219
|
-
for (let i = 1; i < rb; i++) buf[o + i] = buf[o + i] + buf[o + i - 1] & 255;
|
|
8220
|
-
scratch.set(buf.subarray(o, o + rb));
|
|
8221
|
-
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + 4 * i + k] = scratch[k * w + i];
|
|
8222
|
-
} else {
|
|
8223
|
-
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
8224
|
-
}
|
|
8225
|
-
}
|
|
8226
|
-
}
|
|
8227
|
-
function decodeRle(r, l, total) {
|
|
8228
|
-
const rows = l.planes * l.height;
|
|
8229
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8230
|
-
r.checkCount(rows, l.psb ? 4 : 2, "RLE row counts");
|
|
8231
|
-
const counts = new Array(rows);
|
|
8232
|
-
for (let i = 0; i < rows; i++) counts[i] = l.psb ? r.u32() : r.u16();
|
|
8233
|
-
if (total > r.remaining * 130) throw new PsdError("RLE data is too short for its declared size.");
|
|
8234
|
-
const out = new Uint8Array(total);
|
|
8235
|
-
let at = 0;
|
|
8236
|
-
for (const c of counts) at = packbitsDecodeInto(r.bytes(c), rb, out, at);
|
|
8237
|
-
return out;
|
|
8238
|
-
}
|
|
8239
|
-
function decodePlanes(compression, data, l) {
|
|
8240
|
-
const total = decodedLength(l);
|
|
8241
|
-
switch (compression) {
|
|
8242
|
-
case 0:
|
|
8243
|
-
if (data.length < total) throw new PsdError(`Raw channel data has ${data.length} of ${total} bytes.`);
|
|
8244
|
-
return data.slice(0, total);
|
|
8245
|
-
case 1:
|
|
8246
|
-
return decodeRle(new PsdReader(data), l, total);
|
|
8247
|
-
case 2:
|
|
8248
|
-
return inflateChecked(data, total).slice();
|
|
8249
|
-
case 3: {
|
|
8250
|
-
const v = inflateChecked(data, total).slice();
|
|
8251
|
-
unpredict(v, l);
|
|
8252
|
-
return v;
|
|
8253
|
-
}
|
|
8254
|
-
default:
|
|
8255
|
-
throw new PsdError(`Unsupported compression method ${compression}.`);
|
|
8256
|
-
}
|
|
8257
|
-
}
|
|
8258
|
-
function encodeRle(decoded2, l) {
|
|
8259
|
-
const rows = l.planes * l.height;
|
|
8260
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8261
|
-
const cs = l.psb ? 4 : 2;
|
|
8262
|
-
const packed = new Uint8Array(rows * packbitsBound(rb));
|
|
8263
|
-
let at = 0;
|
|
8264
|
-
const counts = new Uint8Array(rows * cs);
|
|
8265
|
-
for (let row = 0; row < rows; row++) {
|
|
8266
|
-
const start = at;
|
|
8267
|
-
at = packbitsEncode(decoded2.subarray(row * rb, (row + 1) * rb), packed, at);
|
|
8268
|
-
const n = at - start;
|
|
8269
|
-
if (cs === 2) {
|
|
8270
|
-
if (n > 65535) throw new PsdError("An RLE row is longer than 65535 bytes; write a PSB instead.");
|
|
8271
|
-
counts[row * 2] = n >> 8;
|
|
8272
|
-
counts[row * 2 + 1] = n & 255;
|
|
8273
|
-
} else {
|
|
8274
|
-
counts[row * 4] = n >>> 24;
|
|
8275
|
-
counts[row * 4 + 1] = n >>> 16 & 255;
|
|
8276
|
-
counts[row * 4 + 2] = n >>> 8 & 255;
|
|
8277
|
-
counts[row * 4 + 3] = n & 255;
|
|
8278
|
-
}
|
|
8279
|
-
}
|
|
8280
|
-
const out = new Uint8Array(counts.length + at);
|
|
8281
|
-
out.set(counts);
|
|
8282
|
-
out.set(packed.subarray(0, at), counts.length);
|
|
8283
|
-
return out;
|
|
8284
|
-
}
|
|
8285
|
-
function predict(buf, l) {
|
|
8286
|
-
const rb = rowBytes(l.width, l.depth);
|
|
8287
|
-
if (rb === 0) return;
|
|
8288
|
-
const w = l.width;
|
|
8289
|
-
const scratch = l.depth === 32 ? new Uint8Array(rb) : null;
|
|
8290
|
-
for (let o = 0; o + rb <= buf.length; o += rb) {
|
|
8291
|
-
if (l.depth === 1 || l.depth === 8) {
|
|
8292
|
-
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
8293
|
-
} else if (l.depth === 16) {
|
|
8294
|
-
for (let i = w - 1; i > 0; i--) {
|
|
8295
|
-
const a = buf[o + 2 * i] << 8 | buf[o + 2 * i + 1];
|
|
8296
|
-
const b = buf[o + 2 * i - 2] << 8 | buf[o + 2 * i - 1];
|
|
8297
|
-
const v = a - b & 65535;
|
|
8298
|
-
buf[o + 2 * i] = v >> 8;
|
|
8299
|
-
buf[o + 2 * i + 1] = v & 255;
|
|
8300
|
-
}
|
|
8301
|
-
} else if (l.depth === 32) {
|
|
8302
|
-
scratch.set(buf.subarray(o, o + rb));
|
|
8303
|
-
for (let i = 0; i < w; i++) for (let k = 0; k < 4; k++) buf[o + k * w + i] = scratch[4 * i + k];
|
|
8304
|
-
for (let i = rb - 1; i > 0; i--) buf[o + i] = buf[o + i] - buf[o + i - 1] & 255;
|
|
8305
|
-
} else {
|
|
8306
|
-
throw new PsdError(`ZIP prediction is not defined for depth ${l.depth}.`);
|
|
8307
|
-
}
|
|
8308
|
-
}
|
|
8309
|
-
}
|
|
8310
|
-
function encodeZipPredicted(decoded2, l) {
|
|
8311
|
-
const buf = decoded2.slice();
|
|
8312
|
-
predict(buf, l);
|
|
8313
|
-
return _chunkXFM3OCHUcjs.deflate.call(void 0, buf);
|
|
8314
|
-
}
|
|
8315
|
-
|
|
8316
8409
|
// src/image-editor/psd/smart.ts
|
|
8317
8410
|
var dbl2 = (value) => ({ type: "doub", value });
|
|
8318
8411
|
var unit2 = (u, value) => ({ type: "UntF", unit: u, value });
|
|
@@ -8323,15 +8416,15 @@ var textV = (value) => ({ type: "TEXT", value });
|
|
|
8323
8416
|
var obj2 = (d) => ({ type: "Objc", value: d });
|
|
8324
8417
|
var text = (d, key) => {
|
|
8325
8418
|
const v = descGet(d, key);
|
|
8326
|
-
return _optionalChain([v, 'optionalAccess',
|
|
8419
|
+
return _optionalChain([v, 'optionalAccess', _233 => _233.type]) === "TEXT" ? v.value : void 0;
|
|
8327
8420
|
};
|
|
8328
8421
|
var enumOf2 = (d, key) => {
|
|
8329
8422
|
const v = descGet(d, key);
|
|
8330
|
-
return _optionalChain([v, 'optionalAccess',
|
|
8423
|
+
return _optionalChain([v, 'optionalAccess', _234 => _234.type]) === "enum" ? v.value : void 0;
|
|
8331
8424
|
};
|
|
8332
8425
|
var numbers = (d, key) => {
|
|
8333
8426
|
const v = descGet(d, key);
|
|
8334
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
8427
|
+
if (_optionalChain([v, 'optionalAccess', _235 => _235.type]) !== "VlLs") return null;
|
|
8335
8428
|
const out = [];
|
|
8336
8429
|
for (const it of v.items) {
|
|
8337
8430
|
if (it.type === "doub" || it.type === "UntF" || it.type === "long") out.push(it.value);
|
|
@@ -8526,8 +8619,8 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8526
8619
|
const painted = _chunkCWM3CUUXcjs.contentBounds.call(void 0, mask.surface);
|
|
8527
8620
|
let b = _nullishCoalesce(painted, () => ( { x: 0, y: 0, width: 1, height: 1 }));
|
|
8528
8621
|
if (mask.defaultValue !== 255 && area) {
|
|
8529
|
-
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
8530
|
-
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess',
|
|
8622
|
+
const x0 = Math.min(area.x, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _236 => _236.x]), () => ( area.x)));
|
|
8623
|
+
const y0 = Math.min(area.y, _nullishCoalesce(_optionalChain([painted, 'optionalAccess', _237 => _237.y]), () => ( area.y)));
|
|
8531
8624
|
const x1 = Math.max(area.x + area.width, painted ? painted.x + painted.width : 0);
|
|
8532
8625
|
const y1 = Math.max(area.y + area.height, painted ? painted.y + painted.height : 0);
|
|
8533
8626
|
b = { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };
|
|
@@ -8547,7 +8640,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8547
8640
|
}
|
|
8548
8641
|
var warpStyleOf = (name) => {
|
|
8549
8642
|
if (!name.startsWith("warp")) return null;
|
|
8550
|
-
const s = _optionalChain([name, 'access',
|
|
8643
|
+
const s = _optionalChain([name, 'access', _238 => _238[4], 'optionalAccess', _239 => _239.toLowerCase, 'call', _240 => _240()]) + name.slice(5);
|
|
8551
8644
|
return _chunkEGZM52EOcjs.WARP_STYLES.includes(s) ? s : null;
|
|
8552
8645
|
};
|
|
8553
8646
|
function warpFromDescriptor(w, contents) {
|
|
@@ -8569,7 +8662,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8569
8662
|
if (!arr || arr.type !== "ObAr") return void 0;
|
|
8570
8663
|
const xs = descGet(arr.body, "Hrzn");
|
|
8571
8664
|
const ys = descGet(arr.body, "Vrtc");
|
|
8572
|
-
if (_optionalChain([xs, 'optionalAccess',
|
|
8665
|
+
if (_optionalChain([xs, 'optionalAccess', _241 => _241.type]) !== "UnFl" || _optionalChain([ys, 'optionalAccess', _242 => _242.type]) !== "UnFl" || xs.values.length !== 16 || ys.values.length !== 16) return void 0;
|
|
8573
8666
|
mesh = { us: [0, 1], vs: [0, 1], points: xs.values.map((x, i) => ({ x, y: ys.values[i] })) };
|
|
8574
8667
|
const px2 = mesh.points.map((p) => p.x);
|
|
8575
8668
|
const py = mesh.points.map((p) => p.y);
|
|
@@ -8736,13 +8829,13 @@ function blendOptions(f) {
|
|
|
8736
8829
|
function smartFiltersFromPsd(fx, newId, notes) {
|
|
8737
8830
|
const filters = [];
|
|
8738
8831
|
const list2 = descGet(fx, "filterFXList");
|
|
8739
|
-
for (const v of _optionalChain([list2, 'optionalAccess',
|
|
8832
|
+
for (const v of _optionalChain([list2, 'optionalAccess', _243 => _243.type]) === "VlLs" ? list2.items : []) {
|
|
8740
8833
|
if (v.type !== "Objc" && v.type !== "GlbO") continue;
|
|
8741
8834
|
const item = v.value;
|
|
8742
8835
|
const { blend, opacity } = blendOptionsOf(item);
|
|
8743
8836
|
const enabled = descBool(item, "enab") !== false;
|
|
8744
8837
|
const fltr = descObject(item, "Fltr");
|
|
8745
|
-
const radius = _optionalChain([fltr, 'optionalAccess',
|
|
8838
|
+
const radius = _optionalChain([fltr, 'optionalAccess', _244 => _244.classId]) === BOX_BLUR.classId ? descNumber(fltr, "Rds ") : void 0;
|
|
8746
8839
|
if (radius !== void 0 && radius >= 0 && radius <= 50) {
|
|
8747
8840
|
filters.push({ id: newId(), kind: "blur", enabled, radius, blend, opacity });
|
|
8748
8841
|
continue;
|
|
@@ -9095,7 +9188,7 @@ function readPsd(bytes) {
|
|
|
9095
9188
|
return { header, colorModeData, resources, layers, mergedAlpha, globalBlocks, imageCompression, imageData: r.rest() };
|
|
9096
9189
|
}
|
|
9097
9190
|
function layerBlock(rec, key) {
|
|
9098
|
-
return _optionalChain([rec, 'access',
|
|
9191
|
+
return _optionalChain([rec, 'access', _245 => _245.blocks, 'access', _246 => _246.find, 'call', _247 => _247((b) => b.key === key), 'optionalAccess', _248 => _248.data]);
|
|
9099
9192
|
}
|
|
9100
9193
|
function layerName(rec) {
|
|
9101
9194
|
const luni = layerBlock(rec, "luni");
|
|
@@ -9126,7 +9219,7 @@ function u8Block(rec, key) {
|
|
|
9126
9219
|
function layerTree(file) {
|
|
9127
9220
|
const stack = [[]];
|
|
9128
9221
|
file.layers.forEach((rec, index) => {
|
|
9129
|
-
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call',
|
|
9222
|
+
const kind = _nullishCoalesce(_optionalChain([sectionDivider, 'call', _249 => _249(rec), 'optionalAccess', _250 => _250.kind]), () => ( SECTION_OTHER));
|
|
9130
9223
|
if (kind === SECTION_DIVIDER) {
|
|
9131
9224
|
stack.push([]);
|
|
9132
9225
|
} else if (kind === SECTION_OPEN || kind === SECTION_CLOSED) {
|
|
@@ -9144,7 +9237,7 @@ function layerTree(file) {
|
|
|
9144
9237
|
}
|
|
9145
9238
|
function channelRect(rec, id) {
|
|
9146
9239
|
if (id === CHANNEL_USER_MASK && rec.mask) return rec.mask.rect;
|
|
9147
|
-
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access',
|
|
9240
|
+
if (id === CHANNEL_REAL_USER_MASK && rec.mask) return _nullishCoalesce(_optionalChain([rec, 'access', _251 => _251.mask, 'access', _252 => _252.real, 'optionalAccess', _253 => _253.rect]), () => ( rec.mask.rect));
|
|
9148
9241
|
return rec.rect;
|
|
9149
9242
|
}
|
|
9150
9243
|
function decodeLayerChannel(file, rec, id) {
|
|
@@ -9162,7 +9255,7 @@ function decodeMergedImage(file) {
|
|
|
9162
9255
|
return decodePlanes(file.imageCompression, file.imageData, { planes: channels, width, height, depth, psb });
|
|
9163
9256
|
}
|
|
9164
9257
|
function resource(file, id) {
|
|
9165
|
-
return _optionalChain([file, 'access',
|
|
9258
|
+
return _optionalChain([file, 'access', _254 => _254.resources, 'access', _255 => _255.find, 'call', _256 => _256((r) => r.id === id), 'optionalAccess', _257 => _257.data]);
|
|
9166
9259
|
}
|
|
9167
9260
|
function resolution(file) {
|
|
9168
9261
|
const d = resource(file, 1005);
|
|
@@ -9946,7 +10039,7 @@ function importNode(ctx, node, depth) {
|
|
|
9946
10039
|
if (node.children) {
|
|
9947
10040
|
const props2 = baseProps(ctx, rec, name, notes);
|
|
9948
10041
|
const divider = sectionDivider(rec);
|
|
9949
|
-
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess',
|
|
10042
|
+
const key = _nullishCoalesce(_optionalChain([divider, 'optionalAccess', _258 => _258.blendKey]), () => ( rec.blendKey));
|
|
9950
10043
|
const groupBlend = key === "pass" ? "pass-through" : _nullishCoalesce(PSD_BLEND_KEYS[key], () => ( "normal"));
|
|
9951
10044
|
const children = [];
|
|
9952
10045
|
for (const child of node.children) {
|
|
@@ -9956,7 +10049,7 @@ function importNode(ctx, node, depth) {
|
|
|
9956
10049
|
const group = { type: "group", id: ctx.newId(name), ...props2, blend: groupBlend, children };
|
|
9957
10050
|
const effects2 = recordEffects(ctx, rec, name, notes, true);
|
|
9958
10051
|
if (effects2) group.effects = effects2;
|
|
9959
|
-
if (_optionalChain([divider, 'optionalAccess',
|
|
10052
|
+
if (_optionalChain([divider, 'optionalAccess', _259 => _259.kind]) === SECTION_CLOSED) group.collapsed = true;
|
|
9960
10053
|
const mask2 = recordMask(ctx, rec, name);
|
|
9961
10054
|
if (mask2) group.mask = mask2;
|
|
9962
10055
|
entry.type = "group";
|
|
@@ -10179,7 +10272,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10179
10272
|
const file = ctx.linked.get(placed.idnt);
|
|
10180
10273
|
contents = {
|
|
10181
10274
|
id: placed.idnt || ctx.newId(`${name}-contents`),
|
|
10182
|
-
name: _optionalChain([file, 'optionalAccess',
|
|
10275
|
+
name: _optionalChain([file, 'optionalAccess', _260 => _260.name]) || `${name}.png`,
|
|
10183
10276
|
width,
|
|
10184
10277
|
height,
|
|
10185
10278
|
kind: "raster",
|
|
@@ -10336,7 +10429,7 @@ function psdToLayers(file, options = {}) {
|
|
|
10336
10429
|
if (mode !== "rgb" && header.depth > 8 && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP) {
|
|
10337
10430
|
warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to ${header.depth}-bit RGB.`);
|
|
10338
10431
|
} else if (mode !== "rgb" || header.depth !== 8 && header.depth !== 16 && header.depth !== 32) {
|
|
10339
|
-
const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess',
|
|
10432
|
+
const how = header.colorMode === MODE_CMYK ? ` through ${_nullishCoalesce(_optionalChain([cmykProfile, 'optionalAccess', _261 => _261.name]), () => ( "its profile"))}` : "";
|
|
10340
10433
|
warn.extra.push(`The file is ${header.depth}-bit ${mode}; it was converted to 8-bit RGB${how}.`);
|
|
10341
10434
|
}
|
|
10342
10435
|
let layers = [];
|
|
@@ -10359,6 +10452,16 @@ function psdToLayers(file, options = {}) {
|
|
|
10359
10452
|
const bg = mergedLayer(ctx);
|
|
10360
10453
|
if (bg) layers = [bg];
|
|
10361
10454
|
}
|
|
10455
|
+
let alphaChannels = [];
|
|
10456
|
+
const hasTransparency = header.channels > ctx.colorCount && (file.layers.length === 0 || file.mergedAlpha);
|
|
10457
|
+
const firstAlpha = ctx.colorCount + (hasTransparency ? 1 : 0);
|
|
10458
|
+
if (!ctx.skipPixels && header.channels > firstAlpha) {
|
|
10459
|
+
try {
|
|
10460
|
+
alphaChannels = readAlphaChannels(decodeMergedImage(file), header, firstAlpha, (id) => resource(file, id), (m) => warn.extra.push(m));
|
|
10461
|
+
} catch (e) {
|
|
10462
|
+
warn.extra.push(`The alpha channels could not be read (${e instanceof Error ? e.message : String(e)}).`);
|
|
10463
|
+
}
|
|
10464
|
+
}
|
|
10362
10465
|
const i32 = (b) => b && b.length >= 4 ? new DataView(b.buffer, b.byteOffset, 4).getInt32(0) : void 0;
|
|
10363
10466
|
const angle = i32(resource(file, 1037));
|
|
10364
10467
|
const altitude = i32(resource(file, 1049));
|
|
@@ -10372,6 +10475,7 @@ function psdToLayers(file, options = {}) {
|
|
|
10372
10475
|
patterns: [...ctx.patterns.values()],
|
|
10373
10476
|
...angle !== void 0 || altitude !== void 0 ? { globalLight: { angle: Math.max(-360, Math.min(360, _nullishCoalesce(angle, () => ( 120)))), altitude: Math.max(0, Math.min(90, _nullishCoalesce(altitude, () => ( 30)))) } } : {},
|
|
10374
10477
|
info: { psb: header.psb, depth: header.depth, colorMode: mode, channels: header.channels },
|
|
10478
|
+
...alphaChannels.length ? { alphaChannels } : {},
|
|
10375
10479
|
...cmykProfile ? { sourceMode: { mode: "cmyk", profile: cmykProfile } } : header.colorMode === MODE_LAB ? { sourceMode: { mode: "lab" } } : {},
|
|
10376
10480
|
...resource(file, 1039) ? { iccProfile: resource(file, 1039).slice() } : {},
|
|
10377
10481
|
bitDepth: (header.depth === 16 || header.depth === 32) && header.colorMode !== MODE_INDEXED && header.colorMode !== MODE_BITMAP ? header.depth : 8
|
|
@@ -10442,15 +10546,15 @@ var pct = (d, key, fallback) => num3(d, key, fallback * 100) / 100;
|
|
|
10442
10546
|
var bool = (d, key) => descBool(d, key) === true;
|
|
10443
10547
|
var enumOf3 = (d, key) => {
|
|
10444
10548
|
const v = descGet(d, key);
|
|
10445
|
-
return _optionalChain([v, 'optionalAccess',
|
|
10549
|
+
return _optionalChain([v, 'optionalAccess', _262 => _262.type]) === "enum" ? v.value : void 0;
|
|
10446
10550
|
};
|
|
10447
10551
|
var text2 = (d, key) => {
|
|
10448
10552
|
const v = d ? descGet(d, key) : void 0;
|
|
10449
|
-
return _optionalChain([v, 'optionalAccess',
|
|
10553
|
+
return _optionalChain([v, 'optionalAccess', _263 => _263.type]) === "TEXT" ? v.value : "";
|
|
10450
10554
|
};
|
|
10451
10555
|
var list = (d, key) => {
|
|
10452
10556
|
const v = descGet(d, key);
|
|
10453
|
-
if (_optionalChain([v, 'optionalAccess',
|
|
10557
|
+
if (_optionalChain([v, 'optionalAccess', _264 => _264.type]) !== "VlLs") return [];
|
|
10454
10558
|
return v.items.flatMap((it) => it.type === "Objc" || it.type === "GlbO" ? [it.value] : []);
|
|
10455
10559
|
};
|
|
10456
10560
|
var clamp3 = (v, lo, hi) => Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : lo;
|
|
@@ -10520,8 +10624,8 @@ function contourOf(d, key) {
|
|
|
10520
10624
|
return { name, points };
|
|
10521
10625
|
}
|
|
10522
10626
|
function contourDesc(c) {
|
|
10523
|
-
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
10524
|
-
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess',
|
|
10627
|
+
const name = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _265 => _265.name]), () => ( "Linear"));
|
|
10628
|
+
const points = _nullishCoalesce(_optionalChain([c, 'optionalAccess', _266 => _266.points]), () => ( [
|
|
10525
10629
|
{ input: 0, output: 0 },
|
|
10526
10630
|
{ input: 1, output: 1 }
|
|
10527
10631
|
]));
|
|
@@ -10556,7 +10660,7 @@ function gradientOf(d, notes) {
|
|
|
10556
10660
|
{ position: 0, color: "#000000" },
|
|
10557
10661
|
{ position: 1, color: "#ffffff" }
|
|
10558
10662
|
],
|
|
10559
|
-
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access',
|
|
10663
|
+
style: _nullishCoalesce(_optionalChain([GRADIENT_STYLES, 'access', _267 => _267.find, 'call', _268 => _268(([, id]) => id === enumOf3(d, "Type")), 'optionalAccess', _269 => _269[0]]), () => ( "linear")),
|
|
10560
10664
|
angle: clamp3(num3(d, "Angl", 90), -360, 360),
|
|
10561
10665
|
scale: clamp3(pct(d, "Scl ", 1), 0.1, 1.5),
|
|
10562
10666
|
reverse: bool(d, "Rvrs"),
|
|
@@ -10610,7 +10714,7 @@ function gradientItems(g) {
|
|
|
10610
10714
|
)
|
|
10611
10715
|
)
|
|
10612
10716
|
};
|
|
10613
|
-
const op = _optionalChain([g, 'access',
|
|
10717
|
+
const op = _optionalChain([g, 'access', _270 => _270.opacityStops, 'optionalAccess', _271 => _271.length]) ? g.opacityStops : g.stops.map((s) => ({ position: s.position, opacity: 1 }));
|
|
10614
10718
|
const trns = {
|
|
10615
10719
|
type: "VlLs",
|
|
10616
10720
|
items: op.map(
|
|
@@ -11107,9 +11211,9 @@ function prepareNestedLayers(layers) {
|
|
|
11107
11211
|
if (l.type === "annotation") continue;
|
|
11108
11212
|
let next = l;
|
|
11109
11213
|
if (l.type === "group") next = { ...l, children: prepareNestedLayers(l.children) };
|
|
11110
|
-
else if (l.type === "pixel" && (_optionalChain([l, 'access',
|
|
11214
|
+
else if (l.type === "pixel" && (_optionalChain([l, 'access', _272 => _272.filters, 'optionalAccess', _273 => _273.length]) || l.source === "document")) {
|
|
11111
11215
|
const p = { ...l };
|
|
11112
|
-
if (_optionalChain([l, 'access',
|
|
11216
|
+
if (_optionalChain([l, 'access', _274 => _274.filters, 'optionalAccess', _275 => _275.some, 'call', _276 => _276(isActiveFilter)])) {
|
|
11113
11217
|
const b = l.surface.bounds;
|
|
11114
11218
|
if (b) {
|
|
11115
11219
|
const r = { x: b.x + l.offset.x - 64, y: b.y + l.offset.y - 64, width: b.width + 128, height: b.height + 128 };
|
|
@@ -11126,7 +11230,7 @@ function prepareNestedLayers(layers) {
|
|
|
11126
11230
|
delete p.source;
|
|
11127
11231
|
next = p;
|
|
11128
11232
|
}
|
|
11129
|
-
if (_optionalChain([next, 'access',
|
|
11233
|
+
if (_optionalChain([next, 'access', _277 => _277.mask, 'optionalAccess', _278 => _278.source])) {
|
|
11130
11234
|
next = { ...next };
|
|
11131
11235
|
delete next.mask;
|
|
11132
11236
|
}
|
|
@@ -11232,7 +11336,7 @@ function exportPsd(input) {
|
|
|
11232
11336
|
return {
|
|
11233
11337
|
opacity: Math.round(Math.min(1, Math.max(0, layer.opacity)) * 255),
|
|
11234
11338
|
clipping: layer.clipped ? 1 : 0,
|
|
11235
|
-
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access',
|
|
11339
|
+
flags: (layer.visible ? 0 : LAYER_FLAG_HIDDEN) | (_optionalChain([layer, 'access', _279 => _279.locks, 'optionalAccess', _280 => _280.transparency]) ? LAYER_FLAG_TRANSPARENCY_PROTECTED : 0),
|
|
11236
11340
|
legacyName: name,
|
|
11237
11341
|
blocks
|
|
11238
11342
|
};
|
|
@@ -11289,7 +11393,7 @@ function exportPsd(input) {
|
|
|
11289
11393
|
}
|
|
11290
11394
|
case "pixel": {
|
|
11291
11395
|
if (layer.source === "document") throw new PsdError(`Layer "${layer.name}" reads the document image; resolve its pixels before export.`);
|
|
11292
|
-
if (_optionalChain([layer, 'access',
|
|
11396
|
+
if (_optionalChain([layer, 'access', _281 => _281.filters, 'optionalAccess', _282 => _282.some, 'call', _283 => _283(isActiveFilter)])) throw new PsdError(`Layer "${layer.name}" has live filters; bake them before export.`);
|
|
11293
11397
|
const extra = [];
|
|
11294
11398
|
if (layer.fillOpacity !== void 0 && layer.fillOpacity < 1) {
|
|
11295
11399
|
extra.push({ key: "iOpa", data: Uint8Array.from([Math.round(Math.max(0, layer.fillOpacity) * 255), 0, 0, 0]) });
|
|
@@ -11321,7 +11425,7 @@ function exportPsd(input) {
|
|
|
11321
11425
|
if (c.linked) note("Linked smart objects were embedded (their preview is written as the contents)", layer.name);
|
|
11322
11426
|
linkedFiles.set(idnt, smartContentsFile(c));
|
|
11323
11427
|
}
|
|
11324
|
-
let placedId = _nullishCoalesce(_optionalChain([layer, 'access',
|
|
11428
|
+
let placedId = _nullishCoalesce(_optionalChain([layer, 'access', _284 => _284.psd, 'optionalAccess', _285 => _285.placed]), () => ( psdUuid(`${layer.id}:placed`)));
|
|
11325
11429
|
if (placedIds.has(placedId)) placedId = psdUuid(`${layer.id}:placed:${placedIds.size}`);
|
|
11326
11430
|
placedIds.add(placedId);
|
|
11327
11431
|
if (placedUnchanged(layer, idnt, placedId)) {
|
|
@@ -11331,12 +11435,12 @@ function exportPsd(input) {
|
|
|
11331
11435
|
const filterFX = layer.smartFilters ? filterFXDescriptor(layer.smartFilters, dropped) : void 0;
|
|
11332
11436
|
if (dropped.length) note("Develop smart filters have no Photoshop filter and were left out of the filter list (the layer\u2019s pixels still show them)", layer.name);
|
|
11333
11437
|
const raw = layer.psd && layer.psd.key !== "PlLd" ? parsePlaced(layer.psd.key, layer.psd.data) : null;
|
|
11334
|
-
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess',
|
|
11438
|
+
const spec = { idnt, placed: placedId, placement: layer.placement, size: { width: c.width, height: c.height }, filterFX, template: _optionalChain([raw, 'optionalAccess', _286 => _286.descriptor]) };
|
|
11335
11439
|
const wnotes = [];
|
|
11336
11440
|
extra.push({ key: "PlLd", data: plldBytes(spec) }, { key: "SoLd", data: soldBytes(spec, wnotes) });
|
|
11337
11441
|
for (const n2 of wnotes) note(`A smart object: ${n2}`, layer.name);
|
|
11338
11442
|
}
|
|
11339
|
-
const fm = _optionalChain([layer, 'access',
|
|
11443
|
+
const fm = _optionalChain([layer, 'access', _287 => _287.smartFilters, 'optionalAccess', _288 => _288.mask]);
|
|
11340
11444
|
if (fm && !fm.source) filterItems.push(filterMaskItem(placedId, fm, { x: 0, y: 0, width, height }));
|
|
11341
11445
|
const rec = { ...common2(layer, extra), rect: EMPTY_RECT, channels: [], blendKey: _nullishCoalesce(BLEND_TO_PSD[layer.blend], () => ( "norm")) };
|
|
11342
11446
|
const bounds = _chunkCWM3CUUXcjs.contentBounds.call(void 0, layer.surface);
|
|
@@ -11364,8 +11468,8 @@ function exportPsd(input) {
|
|
|
11364
11468
|
const losses = /* @__PURE__ */ new Set();
|
|
11365
11469
|
for (const b of shapeBlocks(layer, width, height, _nullishCoalesce(input.resolution, () => ( 72)), losses)) extra.push({ key: b.key, data: padEven(b.data) });
|
|
11366
11470
|
for (const n2 of losses) note(n2, layer.name);
|
|
11367
|
-
if (_optionalChain([layer, 'access',
|
|
11368
|
-
if (_optionalChain([layer, 'access',
|
|
11471
|
+
if (_optionalChain([layer, 'access', _289 => _289.fill, 'optionalAccess', _290 => _290.type]) === "pattern") patternIds2.add(layer.fill.patternId);
|
|
11472
|
+
if (_optionalChain([layer, 'access', _291 => _291.stroke, 'optionalAccess', _292 => _292.paint, 'access', _293 => _293.type]) === "pattern") patternIds2.add(layer.stroke.paint.patternId);
|
|
11369
11473
|
} else {
|
|
11370
11474
|
extra.push({ key: "TySh", data: padEven(tyShForLayer(layer)) });
|
|
11371
11475
|
}
|
|
@@ -11409,6 +11513,10 @@ function exportPsd(input) {
|
|
|
11409
11513
|
planes = transparent ? dp : dp.slice(0, 3);
|
|
11410
11514
|
}
|
|
11411
11515
|
}
|
|
11516
|
+
for (const ch of _nullishCoalesce(input.alphaChannels, () => ( []))) {
|
|
11517
|
+
if (ch.data.length !== n) throw new PsdError(`Alpha channel "${ch.name}" has ${ch.data.length} values, expected ${n}.`);
|
|
11518
|
+
planes.push(planeAtDepth(ch.data, depth));
|
|
11519
|
+
}
|
|
11412
11520
|
const planeBytes = n * (depth >> 3);
|
|
11413
11521
|
const merged2 = new Uint8Array(planeBytes * planes.length);
|
|
11414
11522
|
planes.forEach((p, i) => merged2.set(p, i * planeBytes));
|
|
@@ -11429,7 +11537,8 @@ function exportPsd(input) {
|
|
|
11429
11537
|
{ id: 1005, name: "", data: rw.result() },
|
|
11430
11538
|
{ id: 1057, name: "", data: version.result() }
|
|
11431
11539
|
];
|
|
11432
|
-
if (_optionalChain([input, 'access',
|
|
11540
|
+
if (_optionalChain([input, 'access', _294 => _294.iccProfile, 'optionalAccess', _295 => _295.length])) resources.push({ id: 1039, name: "", data: input.iccProfile });
|
|
11541
|
+
resources.push(...alphaChannelResources(_nullishCoalesce(input.alphaChannels, () => ( []))));
|
|
11433
11542
|
if (input.globalLight) {
|
|
11434
11543
|
const i32 = (v) => {
|
|
11435
11544
|
const w = new PsdWriter();
|
|
@@ -11845,4 +11954,4 @@ function exportPsd(input) {
|
|
|
11845
11954
|
|
|
11846
11955
|
|
|
11847
11956
|
|
|
11848
|
-
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|
|
11957
|
+
exports.LEGACY_PROCESS_VERSION = LEGACY_PROCESS_VERSION; exports.LATEST_PROCESS_VERSION = LATEST_PROCESS_VERSION; exports.normalizeProcessVersion = normalizeProcessVersion; exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.LUMA_709 = LUMA_709; exports.IDENTITY_MATRIX3 = IDENTITY_MATRIX3; exports.mulMatrix3 = mulMatrix3; exports.applyMatrix3 = applyMatrix3; exports.invertMatrix3 = invertMatrix3; exports.D65 = D65; exports.bradfordAdaptation = bradfordAdaptation; exports.wbMatrix = wbMatrix; exports.linearSrgbToXy = linearSrgbToXy; exports.TINT_SCALE = TINT_SCALE; exports.MIN_KELVIN = MIN_KELVIN; exports.MAX_KELVIN = MAX_KELVIN; exports.xyToUv = xyToUv; exports.uvToXy = uvToXy; exports.tempTintToXy = tempTintToXy; exports.xyToTempTint = xyToTempTint; exports.AS_SHOT_KELVIN = AS_SHOT_KELVIN; exports.MIRED_PER_TEMPERATURE_UNIT = MIRED_PER_TEMPERATURE_UNIT; exports.temperatureToKelvin = temperatureToKelvin; exports.kelvinToTemperature = kelvinToTemperature; exports.whiteBalanceMatrix = whiteBalanceMatrix; exports.whiteBalanceFromSample = whiteBalanceFromSample; exports.TONE_LUT_SIZE = TONE_LUT_SIZE; exports.toneCurve = toneCurve; exports.buildToneLut = buildToneLut; exports.sampleToneLut = sampleToneLut; exports.normalizeAngle = normalizeAngle; exports.isQuarterTurnSwapped = isQuarterTurnSwapped; exports.getRotatedSize = getRotatedSize; exports.projectImagePoint = projectImagePoint; exports.unprojectCanvasPoint = unprojectCanvasPoint; exports.applyImageProjectionToContext = applyImageProjectionToContext; exports.projectImageRect = projectImageRect; exports.clampCropToImage = clampCropToImage; exports.getViewportProjection = getViewportProjection; exports.getViewportMetrics = getViewportMetrics; exports.canvasToImagePoint = canvasToImagePoint; exports.imageToCanvasPoint = imageToCanvasPoint; exports.mapCropHandle = mapCropHandle; exports.hitTestCrop = hitTestCrop; exports.getCropCursor = getCropCursor; exports.calculateCropDrag = calculateCropDrag; exports.getAnnotationBounds = getAnnotationBounds; exports.hitTestAnnotation = hitTestAnnotation; exports.SELECTION_MODES = SELECTION_MODES; exports.isSelectionMode = isSelectionMode; exports.parseSelectionMode = parseSelectionMode; exports.computeSelectionBounds = computeSelectionBounds; exports.createSelectionMask = createSelectionMask; exports.fullSelection = fullSelection; exports.isSelectionEmpty = isSelectionEmpty; exports.selectionValueAt = selectionValueAt; exports.coverageToByte = coverageToByte; exports.selectionFromCoverage = selectionFromCoverage; exports.selectionToCoverage = selectionToCoverage; exports.selectionArea = selectionArea; exports.combineSelections = combineSelections; exports.invertSelection = invertSelection; exports.resizeSelection = resizeSelection; exports.selectionFromPixels = selectionFromPixels; exports.selectionToPixels = selectionToPixels; exports.encodeSelectionRle = encodeSelectionRle; exports.decodeSelectionRle = decodeSelectionRle; exports.serializeSelection = serializeSelection; exports.deserializeSelection = deserializeSelection; exports.hashMaskContent = hashMaskContent; exports.EMPTY_DISTANCE = EMPTY_DISTANCE; exports.distanceTransform = distanceTransform; exports.expandCoverage = expandCoverage; exports.contractCoverage = contractCoverage; exports.borderCoverage = borderCoverage; exports.smoothCoverage = smoothCoverage; exports.featherCoverage = featherCoverage; exports.greyMorphology = greyMorphology; exports.shiftCoverage = shiftCoverage; exports.SELECTION_MODIFY_OPS = SELECTION_MODIFY_OPS; exports.modifySelection = modifySelection; exports.normalizeLayerMask = normalizeLayerMask; exports.layerMaskFromSelection = layerMaskFromSelection; exports.updateLayerMaskProps = updateLayerMaskProps; exports.decodeLayerMask = decodeLayerMask; exports.layerMaskKey = layerMaskKey; exports.layerMaskCoverage = layerMaskCoverage; exports.projectMaskCoverage = projectMaskCoverage; exports.buildLayerMaskPlanes = buildLayerMaskPlanes; exports.ADJUSTMENT_LUT_SIZE = ADJUSTMENT_LUT_SIZE; exports.sampleLut = sampleLut; exports.ADJUSTMENT_KINDS = ADJUSTMENT_KINDS; exports.isAdjustmentKind = isAdjustmentKind; exports.adjustmentKindLabel = adjustmentKindLabel; exports.HUE_RANGE_LABELS = HUE_RANGE_LABELS; exports.neutralHueRange = neutralHueRange; exports.identityCurve = identityCurve; exports.identityLevels = identityLevels; exports.defaultAdjustmentParams = defaultAdjustmentParams; exports.createAdjustmentLayer = createAdjustmentLayer; exports.normalizeAdjustmentLayer = normalizeAdjustmentLayer; exports.normalizeAdjustmentLayers = normalizeAdjustmentLayers; exports.curveLutFromLevels = curveLutFromLevels; exports.levelsValue = levelsValue; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.hueRangeWeight = hueRangeWeight; exports.hueRangeTables = hueRangeTables; exports.hueSaturation = hueSaturation; exports.rangeLightness = rangeLightness; exports.VIBRANCE_GREY = VIBRANCE_GREY; exports.vibranceLinear = vibranceLinear; exports.vibrancePixel = vibrancePixel; exports.colorBalanceChannel = colorBalanceChannel; exports.blackWhiteGray = blackWhiteGray; exports.D50 = D50; exports.XYZ_D50_TO_SRGB = XYZ_D50_TO_SRGB; exports.photoFilterMatrix = photoFilterMatrix; exports.posterizeValue = posterizeValue; exports.rgbToGray = rgbToGray; exports.hexToRgb = hexToRgb; exports.toneLuts = toneLuts; exports.compileAdjustmentLayer = compileAdjustmentLayer; exports.activeAdjustmentLayers = activeAdjustmentLayers; exports.evaluateAdjustmentLayers = evaluateAdjustmentLayers; exports.applyAdjustmentLayers = applyAdjustmentLayers; exports.applyAdjustmentLayersFloat = applyAdjustmentLayersFloat; exports.adjustmentLayersKey = adjustmentLayersKey; exports.applyAdjustments = applyAdjustments; exports.applyLegacyAdjustments = applyLegacyAdjustments; exports.applyLegacyFloat = applyLegacyFloat; exports.applyProcess2Adjustments = applyProcess2Adjustments; exports.applyProcess2Float = applyProcess2Float; exports.applyBoxBlurFloat = applyBoxBlurFloat; exports.applyBoxBlur = applyBoxBlur; exports.applyDepthMask = applyDepthMask; exports.removeAlpha = removeAlpha; exports.TEXT_ALIGNS = TEXT_ALIGNS; exports.MAX_EFFECT_ANIMATION_MS = MAX_EFFECT_ANIMATION_MS; exports.SHAPE_OPERATIONS = SHAPE_OPERATIONS; exports.LIVE_SHAPE_KINDS = LIVE_SHAPE_KINDS; exports.newLayerId = newLayerId; exports.pixelLayers = pixelLayers; exports.developFilter = developFilter; exports.blurFilter = blurFilter; exports.isActiveFilter = isActiveFilter; exports.isSpatialFilter = isSpatialFilter; exports.pixelLayerBounds = pixelLayerBounds; exports.layerTypeLabel = layerTypeLabel; exports.hasSurface = hasSurface; exports.isRenderedLayer = isRenderedLayer; exports.shapeLayers = shapeLayers; exports.smartObjectLayers = smartObjectLayers; exports.adjustmentNodeAsLayer = adjustmentNodeAsLayer; exports.depthMaskAlpha = depthMaskAlpha; exports.runLayerFilters = runLayerFilters; exports.runLayerFiltersFloat = runLayerFiltersFloat; exports.LayerCompositor = LayerCompositor; exports.compositeDeep = compositeDeep; exports.DEFAULT_ADJUSTMENTS_VALUES = DEFAULT_ADJUSTMENTS_VALUES; exports.DEFAULT_TRANSFORM_VALUES = DEFAULT_TRANSFORM_VALUES; exports.DEFAULT_DEPTH_MASK_VALUES = DEFAULT_DEPTH_MASK_VALUES; exports.flattenPath = flattenPath; exports.rasterizeCoverage = rasterizeCoverage; exports.LayerOperationError = LayerOperationError; exports.userErrorMessage = userErrorMessage; exports.isPaintableLayer = isPaintableLayer; exports.defaultActiveLayerId = defaultActiveLayerId; exports.activeLayerAfterRemoval = activeLayerAfterRemoval; exports.requireLayer = requireLayer; exports.requireUnlocked = requireUnlocked; exports.placeLayer = placeLayer; exports.removeLayer = removeLayer; exports.moveLayer = moveLayer; exports.withNewIds = withNewIds; exports.duplicateLayer = duplicateLayer; exports.setLayerProperties = setLayerProperties; exports.groupLayers = groupLayers; exports.ungroupLayer = ungroupLayer; exports.offsetLayer = offsetLayer; exports.setLayerMask = setLayerMask; exports.normalizeFilter = normalizeFilter; exports.addLayerFilter = addLayerFilter; exports.updateLayerFilter = updateLayerFilter; exports.removeLayerFilter = removeLayerFilter; exports.layerEffectsOf = layerEffectsOf; exports.setLayerEffects = setLayerEffects; exports.addLayerEffect = addLayerEffect; exports.updateLayerEffect = updateLayerEffect; exports.removeLayerEffect = removeLayerEffect; exports.setLayerEffectsEnabled = setLayerEffectsEnabled; exports.parseBlend = parseBlend; exports.unionRect = unionRect; exports.SHAPE_RENDER_MARGIN = SHAPE_RENDER_MARGIN; exports.DEFAULT_MITER_LIMIT = DEFAULT_MITER_LIMIT; exports.mapSubpaths = mapSubpaths; exports.liveShapeSubpaths = liveShapeSubpaths; exports.liveComponent = liveComponent; exports.componentPath = componentPath; exports.shapeOutline = shapeOutline; exports.shapeGeometryBounds = shapeGeometryBounds; exports.shapeRenderClip = shapeRenderClip; exports.renderShapeRect = renderShapeRect; exports.renderShape = renderShape; exports.rerenderShape = rerenderShape; exports.normalizeShapePaint = normalizeShapePaint; exports.normalizeShapeStroke = normalizeShapeStroke; exports.normalizeLiveShape = normalizeLiveShape; exports.normalizeSubpaths = normalizeSubpaths; exports.requireOperation = requireOperation; exports.requireShapeLayer = requireShapeLayer; exports.createShapeLayer = createShapeLayer; exports.defaultShapeName = defaultShapeName; exports.updateShapeLayer = updateShapeLayer; exports.transformShapeComponents = transformShapeComponents; exports.offsetShape = offsetShape; exports.mergeShapeComponents = mergeShapeComponents; exports.shapeAsPixelLayer = shapeAsPixelLayer; exports.shapeFromAnnotation = shapeFromAnnotation; exports.annotationBlend = annotationBlend; exports.annotationOfShape = annotationOfShape; exports.TEXT_RENDER_MARGIN = TEXT_RENDER_MARGIN; exports.textMatrix = textMatrix; exports.textOutlines = textOutlines; exports.renderText = renderText; exports.rerenderText = rerenderText; exports.TEXT_STYLE_FIELDS = TEXT_STYLE_FIELDS; exports.patchTextStyle = patchTextStyle; exports.PARAGRAPH_STYLE_FIELDS = PARAGRAPH_STYLE_FIELDS; exports.patchParagraphStyle = patchParagraphStyle; exports.textRange = textRange; exports.requireTypeLayer = requireTypeLayer; exports.normalizeText = normalizeText; exports.typeLayerName = typeLayerName; exports.createTypeLayer = createTypeLayer; exports.updateTypeLayer = updateTypeLayer; exports.replaceTextRange = replaceTextRange; exports.transformTypeLayer = transformTypeLayer; exports.typeFrame = typeFrame; exports.typeAsPixelLayer = typeAsPixelLayer; exports.toTextSpace = toTextSpace; exports.typeFromAnnotation = typeFromAnnotation; exports.annotationOfType = annotationOfType; exports.BACKGROUND_LAYER_ID = BACKGROUND_LAYER_ID; exports.BACKGROUND_LAYER_NAME = BACKGROUND_LAYER_NAME; exports.DEVELOP_FILTER_ID = DEVELOP_FILTER_ID; exports.BLUR_FILTER_ID = BLUR_FILTER_ID; exports.rasterMaskFromLegacy = rasterMaskFromLegacy; exports.hasResampledLegacyMask = hasResampledLegacyMask; exports.legacyMaskOf = legacyMaskOf; exports.isDefaultDepthMask = isDefaultDepthMask; exports.developFromAdjustments = developFromAdjustments; exports.annotationLayerName = annotationLayerName; exports.annotationLayerFor = annotationLayerFor; exports.annotationOfLayer = annotationOfLayer; exports.adjustmentNodeFromLegacy = adjustmentNodeFromLegacy; exports.backgroundLayer = backgroundLayer; exports.depthRasterMask = depthRasterMask; exports.layersFromLegacy = layersFromLegacy; exports.legacyAdjustmentLayer = legacyAdjustmentLayer; exports.developTarget = developTarget; exports.legacyView = legacyView; exports.isLegacyShape = isLegacyShape; exports.FREE_TRANSFORM_MODES = FREE_TRANSFORM_MODES; exports.TRANSFORM_ANCHORS = TRANSFORM_ANCHORS; exports.ANCHOR_FRACTION = ANCHOR_FRACTION; exports.isTransformAnchor = isTransformAnchor; exports.identityTransform = identityTransform; exports.cornersFromMatrix = cornersFromMatrix; exports.matrixFromCorners = matrixFromCorners; exports.transformHomography = transformHomography; exports.hasWarp = hasWarp; exports.isIdentityTransform = isIdentityTransform; exports.transformMap = transformMap; exports.transformedPoint = transformedPoint; exports.anchorPoint = anchorPoint; exports.transformedBox = transformedBox; exports.referencePoint = referencePoint; exports.matrixFromParams = matrixFromParams; exports.describeTransform = describeTransform; exports.applyParams = applyParams; exports.flipCorners = flipCorners; exports.boxPointOf = boxPointOf; exports.presetWarp = presetWarp; exports.isValidWarp = isValidWarp; exports.geometryHomography = geometryHomography; exports.SMART_RENDER_MARGIN = SMART_RENDER_MARGIN; exports.isSmartSurfaceIncomplete = isSmartSurfaceIncomplete; exports.newContentsId = newContentsId; exports.contentsBox = contentsBox; exports.placementGeometry = placementGeometry; exports.placementAt = placementAt; exports.isContentsDecoded = isContentsDecoded; exports.requireSmartObject = requireSmartObject; exports.contentsSurface = contentsSurface; exports.rasterContents = rasterContents; exports.documentContents = documentContents; exports.placeContents = placeContents; exports.activeSmartFilters = activeSmartFilters; exports.activeEffectSmartFilters = activeEffectSmartFilters; exports.filterMaskCoverage = filterMaskCoverage; exports.applySmartFilters = applySmartFilters; exports.renderSmartObject = renderSmartObject; exports.rerender = rerender; exports.normalizePlacement = normalizePlacement; exports.setSmartPlacement = setSmartPlacement; exports.offsetSmartObject = offsetSmartObject; exports.translateLayer = translateLayer; exports.convertToSmartObject = convertToSmartObject; exports.rasterizeSmartObject = rasterizeSmartObject; exports.copySmartObject = copySmartObject; exports.instancesOf = instancesOf; exports.replaceContents = replaceContents; exports.normalizeSmartFilter = normalizeSmartFilter; exports.addSmartFilter = addSmartFilter; exports.updateSmartFilter = updateSmartFilter; exports.removeSmartFilter = removeSmartFilter; exports.moveSmartFilter = moveSmartFilter; exports.setSmartFiltersEnabled = setSmartFiltersEnabled; exports.setSmartFilterMask = setSmartFilterMask; exports.withFilterMaskSurface = withFilterMaskSurface; exports.placementBounds = placementBounds; exports.LAYERED_SCHEMA_VERSION = LAYERED_SCHEMA_VERSION; exports.serializePatterns = serializePatterns; exports.deserializePatterns = deserializePatterns; exports.encodeSurface = encodeSurface; exports.encodeDeepSurface = encodeDeepSurface; exports.decodeDeepSurface = decodeDeepSurface; exports.serializeEffects = serializeEffects; exports.deserializeEffects = deserializeEffects; exports.serializeLayer = serializeLayer; exports.serializeContents = serializeContents; exports.serializeLayers = serializeLayers; exports.serializeLayersExternal = serializeLayersExternal; exports.resolveExternalAssets = resolveExternalAssets; exports.decodePngDataUrl = decodePngDataUrl; exports.deserializeLayer = deserializeLayer; exports.deserializeLayers = deserializeLayers; exports.PsdError = PsdError; exports.decodePlanes = decodePlanes; exports.encodeRle = encodeRle; exports.parseVersionedDescriptor = parseVersionedDescriptor; exports.versionedDescriptorBytes = versionedDescriptorBytes; exports.ADJUSTMENT_KEYS = ADJUSTMENT_KEYS; exports.SUPPORTED_ADJUSTMENT_KEYS = SUPPORTED_ADJUSTMENT_KEYS; exports.parseAdjustmentBlock = parseAdjustmentBlock; exports.writeAdjustmentBlock = writeAdjustmentBlock; exports.parseLfx2 = parseLfx2; exports.writeLfx2 = writeLfx2; exports.parseLrfx = parseLrfx; exports.BROWSER_IMAGE_TYPES = BROWSER_IMAGE_TYPES; exports.readPsd = readPsd; exports.layerName = layerName; exports.layerTree = layerTree; exports.decodeLayerChannel = decodeLayerChannel; exports.decodeMergedImage = decodeMergedImage; exports.writePsd = writePsd; exports.PATTERN_BLOCK_KEYS = PATTERN_BLOCK_KEYS; exports.parsePatternBlock = parsePatternBlock; exports.psdPatternToEffectPattern = psdPatternToEffectPattern; exports.writePatternBlock = writePatternBlock; exports.PSD_BLEND_KEYS = PSD_BLEND_KEYS; exports.psdToLayers = psdToLayers; exports.importPsd = importPsd; exports.smartContentsFile = smartContentsFile; exports.exportPsd = exportPsd;
|